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( )
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access