The Text Class
JDOM uses the Text class internally to represent text nodes. In normal usage, you don't deal with this class directly—you just use strings. The one time you may encounter it is when you use getContent() to retrieve all the children of the node, and you're iterating through the list returned. In this case, you will see Text objects.
Each Text object has a parent Element (which may be null) and a String value that holds the content of the node. This value may contain characters like < and &. If so, they will be escaped when the node is serialized. They do not need to be escaped before being inserted into a Text object.
The Text class, summarized in Example 15.11, has methods to get, set, and detach the parent Element; to get and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access