public interface Text extends CharacterData
In the DOM, the Text interface represents the textual content of an Element or Attr. If an element has no markup within its content, it has a single child implementing Text that contains the element's text. However, if the element contains markup, it is parsed into information items and Text nodes that form its children.
New documents have a single Text node for each block of text. Over time, more Text nodes may be created as the document's content changes. The Node.normalize()
method merges adjacent Text objects back into a single node for each block of text.
Text also implements the CharacterData interface (which implements the Node interface).
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
Modifier and Type | Method and Description |
---|---|
String |
getWholeText()
Returns all text of all Text nodes logically adjacent to this node, concatenated in document order.
|
Text |
replaceWholeText(String content)
Replaces the text of the current node and all logically adjacent nodes with the specified text.
|
Text |
splitText(int offset)
Breaks the node into two nodes at a specified offset.
|
appendData, deleteData, getData, getLength, insertData, replaceData, setData, substringData
addEventListener, addEventListener, appendChild, cloneNode, compareDocumentPosition, contains, dispatchEvent, getAttributes, getBaseURI, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPrefix, getPreviousSibling, getTextContent, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, removeEventListener, removeEventListener, replaceChild, setNodeValue, setPrefix, setTextContent
String getWholeText()
Text replaceWholeText(String content)
Text splitText(int offset)
Copyright © 2018. All rights reserved.