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 }