Name

NodeList

Synopsis

The NodeList interface allows DOM classes to expose an ordered collection of nodes. A NodeList represents a read-only, zero-based array of Node objects. Since no mechanism exists for creating, adding, or removing nodes from a NodeList, DOM users cannot use this class as a general-purpose utility class.

Java example

// List the text contents of an element
NodeList nlChildren = elem.getChildNodes( );
Node ndChild;
     
for (int iNode = 0; iNode < nlChildren.getLength( ); iNode++) {
    ndChild = nlChildren.item(iNode);
     
    if (ndChild.getNodeType( ) =  = Node.TEXT_NODE) {
        System.out.println(ndChild.getNodeValue( ));
    }
}

Attribute

The NodeList interface defines one attribute:

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.