Class Text Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The
Textclass represents an XML text node.Methods are available to append, detach, get the parent element, get the text value, get the combined value of child nodes, and set the text value.
The
append()method adds text to the existing content and returns theTextnode for chaining.The
detach()method removes the node from its parent and returns the detached node.The
getParentElement()method returns the node's parentElementornullif there is no parent.The
getText()method retrieves the specific text content of theTextnode.The
getValue()method retrieves the combined text content of all child nodes, direct and indirect.The
setText()method replaces the existing text content and returns theTextnode for chaining.
A representation of an XMLText node.
Methods
| Method | Return type | Brief description |
|---|---|---|
append(text) | Text | Appends the given text to any content that already exists in the node. |
detach() | Content | Detaches the node from its parentElement node. |
get | Element | Gets the node's parentElement node. |
get | String | Gets the text value of theText node. |
get | String | Gets the text value of all nodes that are direct or indirect children of the node, in the orderthey appear in the document. |
set | Text | Sets the text value of theText node. |
Detailed documentation
append(text)
Appends the given text to any content that already exists in the node.
Parameters
| Name | Type | Description |
|---|---|---|
text | String | the text to append to the node |
Return
Text — theText node, for chaining
detach()
getParentElement()
getText()
Gets the text value of theText node.
Return
String — the text value of theText node
getValue()
Gets the text value of all nodes that are direct or indirect children of the node, in the orderthey appear in the document.
Return
String — the text value of all nodes that are direct or indirect children of the node
setText(text)
Sets the text value of theText node.
Parameters
| Name | Type | Description |
|---|---|---|
text | String | the text value to set |
Return
Text — theText node, for chaining
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.