> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/huong-dan-cac-action/element/get-element-text.md).

# Get element text

Hành động này giúp tool "đọc" và lấy toàn bộ chữ hiển thị trên một phần tử (như nội dung bài viết, tiêu đề, giá tiền, hay tên tài khoản) rồi lưu vào một biến để bạn sử dụng.

* Tác dụng: Dùng khi bạn cần cào dữ liệu văn bản từ website. Bạn chỉ cần chỉ định đúng vị trí (element), tool sẽ tự động bóc tách phần chữ đang hiển thị trên giao diện ra cho bạn.

#### Giải thích các tham số cấu hình:

* XPath: Đường dẫn mã định danh (XPath) của phần tử chứa đoạn văn bản cần lấy trên giao diện trang web.
* Output variable: Tên biến số để lưu lại nội dung văn bản sau khi bóc tách thành công.

#### Ví dụ thực tế: Cào giá tiền của sản phẩm

Dựa trên hình ảnh giao diện cửa hàng mà bạn cung cấp, bạn muốn cào mức giá của chiếc điện thoại Samsung galaxy s6 để phục vụ việc so sánh giá hoặc đồng bộ dữ liệu lên hệ thống của mình.

Nhìn vào bảng mã nguồn HTML được khoanh đỏ bên phải hình dưới:

> Cấu trúc thẻ chứa giá tiền: `<h5>$360</h5>`

Để lấy được chuỗi văn bản giá tiền `$360` này, bạn sẽ cấu hình hành động như sau:

* Element XPath: Nhập chính xác đường dẫn XPath đang chỉ thẳng vào thẻ chứa giá tiền của sản phẩm đó, ví dụ: `//div[@class='card h-100']//h5` (như ô tìm kiếm XPath bạn đã kiểm tra thành công trong hình).
* Output variable: Đặt tên biến đầu ra là `productPrice`.

Kết quả: Hệ thống sẽ tìm đến thẻ `<h5>` tương ứng của sản phẩm, bóc tách phần văn bản thuần nằm ở giữa thẻ và nạp thẳng giá trị `$360` vào biến `$productPrice`. Ở các bước sau, bạn có thể gọi biến này ra để ghi vào file Excel hoặc gửi lên dữ liệu hệ thống.

<figure><img src="/files/i8AfnM4PskfAagzhxkWt" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/AH2iGgBKtekxkxmcBVeK" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/huong-dan-cac-action/element/get-element-text.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
