Name

NodeList

Synopsis

This interface represents a read-only ordered collection of nodes that can be interated through. getLength( ) returns the number of nodes in the list, and item( ) returns the Node at a specified index in the list (the index of the first node is 0). The elements of a NodeList are always valid Node objects: a NodeList never contains null elements.

Note that NodeList objects are “live”—they are not static but immediately reflect changes to the document tree. For example, if you have a NodeList that represents the children of a specific node, and you then delete one of those children, the child will be removed from your NodeList. Be careful when looping through the elements of a NodeList if the body of your loop makes changes to the document tree (such as deleting nodes) that may affect the contents of the NodeList!

public interface NodeList {
// Public Instance Methods
     int getLength( );  
     Node item(int index);  
}

Returned By

Document.{getElementsByTagName( ), getElementsByTagNameNS( )}, Element.{getElementsByTagName( ), getElementsByTagNameNS( )}, Node.getChildNodes( )

Get Java in a Nutshell, 5th 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.