The Text Interface
The Text interface represents a text node. This can be a child of an element, an attribute, or an entity reference. When a document is built by a parser, each text node will contain the longest possible run of contiguous parsed character data from the document, and thus no text node will be adjacent to any other. By contrast, documents built in memory may contain adjacent text nodes. Invoking the normalize() method in the Node interface on any ancestor of the text nodes will merge these together.
Example 11.9 summarizes the Text interface. In addition to methods such as setData() and getNodeValue() that Text inherits from its superinterfaces, it has one new method that splits a Text object into two.
Example 11.9. The Text Interface ...
Get Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.