HomeAPIGuideSF Project Home

JAPI Guide: XML

This part of the guide provides XML related articles.

NodeListIterator

The class NodeListIterator provides access to Java 5.0 syntax when iterating over XML nodes.

Without JAPI:

final NodeList nl = doc.getElementsByTagName("style");
for (int i = 0; i < nl.getLength(); i++) {
    final Element styleElement = (Element) nl.item(i);
    // do something with styleElement
}

With JAPI:

final NodeList nl = doc.getElementsByTagName("style");
for (final Element styleElement : new NodeListIterator<Element>(nl)) {
    // do something with styleElement
}

Or even shorter:

for (final Element styleElement : new NodeListIterator<Element>(doc.getElementsByTagName("style"))) {
    // do something with styleElement
}
SourceForge.net LogoSupport This ProjectValid HTML 4.01!Valid CSS! Feedback: webmaster
$Date: 2006-04-03 23:00:14 +0200 (Mon, 03 Apr 2006) $