September 2004
Intermediate to advanced
712 pages
24h 45m
English
The NodeList interface provides access to the ordered content of a
node. Most frequently, it is used to retrieve text nodes and child
elements of element nodes. See Table 19-4 for a summary of
the NodeList interface.
Name | Type | Read-only | 2.0 | 3.0 |
Attribute | ||||
length | Long | |||
Method | ||||
item | Node |
The NodeList interface is
extremely basic and is generally combined with a loop to iterate
through the children of a node, as in the following example:
NodeList nl = nd.getChildNodes( );
for (int i = 0; i < nl.getLength( ); i++) {
Node ndChild = nl.item(i);
if (ndChild.getNodeType( ) = = Node.COMMENT_NODE) {
System.out.println("found comment: " + ndChild.getNodeValue( ));
}
}Read now
Unlock full access