NodeList
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.
// 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( )); } }