Name

nodeValue: DOMString

Synopsis

Intended to provide a reasonable string value for the underlying DOM object. Depending on the nodeType, this property may be read-only, read/write, or null. This table lists the values for the object types.

Object type

nodeValue

Element

null

Attr

Attribute value

Text

Text node content

CDATASection

CDATA section content

EntityReference

null

Entity

null

ProcessingInstruction

Entire content, excluding the target

Comment

Comment content

Document

null

DocumentType

null

DocumentFragment

null

Notation

null

Exceptions

NO_MODIFICATION_ALLOWED_ERR

Indicates the nodeValue attribute is read-only for this DOM object type.

DOMSTRING_SIZE_ERR

This exception is raised if the value that would be returned is too large to be contained by a DOMString type in the given implementation.

Java bindings

public String getNodeValue( ) throws DOMException;
public void setNodeValue(String nodeValue) throws DOMException;

Java example

// If this node is a text node, make the value lowercase
if (nd.getNodeType( ) =  = Node.TEXT_NODE) {
    // make it lowercase
    nd.setNodeValue(nd.getNodeValue( ).toLowerCase( ));
}

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.