External Iterators
You can use external iterators to drive the entire parsing process like so :
for (NodeIterator i = parser.elements();i.hasMoreNodes();) {
Node node = e.nextNode();
if (node instanceof LinkTag) {
}
if (node instanceof ImageTag) {
}
}
You should think of this only when you want to conduct a really quick search, and the moment you've found what you've wanted, you want to stop parsing. The iterator here drives the parsing.