Java tutorial
//package com.java2s; import org.w3c.dom.Node; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; public class Main { public static Node getNode(Node node, XPathExpression xpath) { try { Object result = xpath.evaluate(node, XPathConstants.NODE); return (Node) result; } catch (XPathExpressionException e) { throw new RuntimeException("Invalid XPath", e); } } }