Java tutorial
//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.Document; public class Main { private static XPath _xpath = XPathFactory.newInstance().newXPath(); /** * Use the supplied XPath statement find the data. * */ public static String findString(Document document, String xpath) { try { return (String) _xpath.evaluate(xpath, document, XPathConstants.STRING); } catch (XPathExpressionException e) { e.printStackTrace(); } return null; } }