How I use org.w3c.dom.traversal.NodeIterator for iterate Nodes in java using Xpath
I have the follos code but doesn't work.
import org.w3c.dom.traversal.NodeIterator;
NodeIterator products = XPathAPI.selectNodeIterator(document, "/ONIXMessage/Product");
while(products.hasNext()) {
Node element = products.nextNode();
.......
}
I don't know what I have to put in the while condition
A W3C DOM NodeIterator should be used as follows:
If you still have problems then show us a sample of the XML input. Usually namespaces are the reason that XPath expressions don't select what users want them to select.