// Use the DOM L3 XPath API to apply the xpath expression to the doc.
System.out.println("Querying DOM using "+xpath);
// Create an XPath evaluator and pass in the document.
XPathEvaluator evaluator = new XPathEvaluatorImpl(doc);
XPathNSResolver resolver = evaluator.createNSResolver(doc);
// Evaluate the xpath expression
XPathResult result = (XPathResult)evaluator.evaluate(xpath, doc, resolver, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);