A Text node represents a run of plain text that does not contain any XML markup. Plain text appears within XML elements and attributes, and Text nodes typically appear as children of Element and Attr nodes. Text nodes inherit from CharacterData , and the textual content of a Text node is available through the getdata( ) method inherited from CharacterData or through the getNodeValue( ) method inherited from Node . Text nodes may be manipulated using any of the methods inherited from CharacterData . The Text interface defines one method of its own: splitText( ) splits a Text node at the specified character position. The method changes the original node so that it contains only the text up to the specified position. Then it creates a new Text node that contains the text from the specified position on and inserts that new node into the document tree immediately after the original one. The Node.normalize( ) method reverses this process by deleting emty Text nodes and merging adjacent Text nodes into a single node. Text nodes never have children. Figure 21-14. org.w3c.dom.Textpublic interface Text extends CharacterData { // Public Instance Methods 5.0 String getWholeText ( ); 5.0 boolean isElementContentWhitespace ( ); 5.0 Text replaceWholeText (String content ) throws DOMException; Text splitText (int offset ) throws DOMException; } ImplementationsCDATASection Returned ByDocument.createTextNode( ) |