Java examples for XML:XPath
evaluate Xpath Node
//package com.java2s; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Node; public class Main { public static Node evaluateXpathNode(Node rootNode, String xPathQuery) throws XPathExpressionException { XPath xPath = XPathFactory.newInstance().newXPath(); return (Node) xPath.compile(xPathQuery).evaluate(rootNode, XPathConstants.NODE); }//w w w . j ava2 s .c o m }