Name
textContent: DOMString(3)
Synopsis
This attribute provides a quick method to get and
set the textual content of nodes within the document tree. When
used to retrieve text, it returns the contents of all descendant
Text
nodes without any
whitespace normalization. Markup nodes (Attr
, Element
, and so forth) are ignored. When
used to set text, it causes any child nodes to be removed and a
single Text
node to be created
and linked in as the only child of the target node. The following
table shows how the textContent
attribute is constructed for the various node types:
Node type | Value |
| Combines the |
| Returns the same value as the |
| Returns |
Exceptions
- NO_MODIFICATION_ALLOWED_ERR
Thrown on set if node is read-only.
- DOMSTRING_SIZE_ERR
Thrown on get when length of text content would exceed the maximum allowable length of a
DOMString
on the implementation platform.
Java binding
public String getTextContent( ); public void setTextContent(String textContent) throws DOMException
Methods
The following methods are defined for Node
interface objects:
Get XML in a Nutshell, 3rd Edition 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.