This method takes a file, and searches it for specific
pieces of data using DOM traversal.
// Parse into a DOM tree
File file = new File(filename);
DOMParser parser = new DOMParser();
parser.parse(file.toURL().toString());
Document doc = parser.getDocument();
// Get node to start iterating with
Element root = doc.getDocumentElement();
NodeList descriptionElements =
root.getElementsByTagNameNS(docNS, "description");
Element description = (Element)descriptionElements.item(0);
// Get a NodeIterator
NodeIterator i = ((DocumentTraversal)doc)
.createNodeIterator(description, NodeFilter.SHOW_ALL,
new FormattingNodeFilter(), true);
Node n;
while ((n = i.nextNode()) != null) {
System.out.println("Search phrase found: '" + n.getNodeValue() + "'");
}