Class Text
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Văn bản
Biểu thị nút Text
XML.
Tài liệu chi tiết
append(text)
Thêm văn bản đã cho vào bất kỳ nội dung nào đã tồn tại trong nút.
Tham số
Tên | Loại | Mô tả |
text | String | văn bản cần nối vào nút |
Cầu thủ trả bóng
Text
– nút Text
, để tạo chuỗi
detach()
Tách nút này khỏi nút Element
mẹ. Nếu nút không có nút mẹ, phương thức này sẽ không có hiệu lực.
Cầu thủ trả bóng
Content
– nút đã tách
getParentElement()
Lấy nút Element
mẹ của nút. Nếu nút không có nút mẹ, phương thức này sẽ trả về null
.
Cầu thủ trả bóng
Element
– nút Element
mẹ
getText()
Lấy giá trị văn bản của nút Text
.
Cầu thủ trả bóng
String
– giá trị văn bản của nút Text
getValue()
Lấy giá trị văn bản của tất cả các nút là phần tử con trực tiếp hoặc gián tiếp của nút, theo thứ tự xuất hiện trong tài liệu.
Cầu thủ trả bóng
String
– giá trị văn bản của tất cả các nút là phần tử con trực tiếp hoặc gián tiếp của nút
setText(text)
Đặt giá trị văn bản của nút Text
.
Tham số
Tên | Loại | Mô tả |
text | String | giá trị văn bản cần đặt |
Cầu thủ trả bóng
Text
– nút Text
, để tạo chuỗi
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eText\u003c/code\u003e object represents a text node within an XML document and provides methods for manipulating its content.\u003c/p\u003e\n"],["\u003cp\u003eYou can use methods like \u003ccode\u003eappend()\u003c/code\u003e, \u003ccode\u003esetText()\u003c/code\u003e, and \u003ccode\u003egetText()\u003c/code\u003e to modify and retrieve the text content of the node.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003edetach()\u003c/code\u003e removes the node from its parent element, while \u003ccode\u003egetParentElement()\u003c/code\u003e allows access to the parent element.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetValue()\u003c/code\u003e retrieves the text value of all child nodes, offering a way to access nested content within the text node.\u003c/p\u003e\n"]]],["The `Text` node represents XML text content. Key actions include: appending text to the node via `append(text)`, detaching the node from its parent using `detach()`, and retrieving the parent element with `getParentElement()`. Text content can be obtained using `getText()` for the node's text or `getValue()` for text of child nodes. Finally, `setText(text)` sets the text value of the node. These methods allow manipulation and reading of text in an XML structure.\n"],null,["# Class Text\n\nText\n\nA representation of an XML `Text` node. \n\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------------|-------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [append(text)](#append(String)) | [Text](#) | Appends the given text to any content that already exists in the node. |\n| [detach()](#detach()) | [Content](/apps-script/reference/xml-service/content) | Detaches the node from its parent [Element](/apps-script/reference/xml-service/element) node. |\n| [getParentElement()](#getParentElement()) | [Element](/apps-script/reference/xml-service/element) | Gets the node's parent [Element](/apps-script/reference/xml-service/element) node. |\n| [getText()](#getText()) | `String` | Gets the text value of the `Text` node. |\n| [getValue()](#getValue()) | `String` | Gets the text value of all nodes that are direct or indirect children of the node, in the order they appear in the document. |\n| [setText(text)](#setText(String)) | [Text](#) | Sets the text value of the `Text` node. |\n\nDetailed documentation\n----------------------\n\n### `append(text)`\n\nAppends the given text to any content that already exists in the node.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|----------|--------------------------------|\n| `text` | `String` | the text to append to the node |\n\n#### Return\n\n\n[Text](#) --- the `Text` node, for chaining\n\n*** ** * ** ***\n\n### `detach()`\n\nDetaches the node from its parent [Element](/apps-script/reference/xml-service/element) node. If the node does not have a parent,\nthis method has no effect.\n\n#### Return\n\n\n[Content](/apps-script/reference/xml-service/content) --- the detached node\n\n*** ** * ** ***\n\n### `get``Parent``Element()`\n\nGets the node's parent [Element](/apps-script/reference/xml-service/element) node. If the node does not have a parent, this method\nreturns `null`.\n\n#### Return\n\n\n[Element](/apps-script/reference/xml-service/element) --- the parent `Element` node\n\n*** ** * ** ***\n\n### `get``Text()`\n\nGets the text value of the `Text` node.\n\n#### Return\n\n\n`String` --- the text value of the `Text` node\n\n*** ** * ** ***\n\n### `get``Value()`\n\nGets the text value of all nodes that are direct or indirect children of the node, in the order\nthey appear in the document.\n\n#### Return\n\n\n`String` --- the text value of all nodes that are direct or indirect children of the node\n\n*** ** * ** ***\n\n### `set``Text(text)`\n\nSets the text value of the `Text` node.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|----------|-----------------------|\n| `text` | `String` | the text value to set |\n\n#### Return\n\n\n[Text](#) --- the `Text` node, for chaining"]]