Java tutorial
//package com.java2s; import javax.xml.namespace.NamespaceContext; import javax.xml.namespace.QName; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Node; public class Main { private static Object getValue(final String xpathExpression, final Node node, final QName type, final NamespaceContext nsContext) throws XPathExpressionException { final XPathFactory factory = XPathFactory.newInstance(); final XPath xpath = factory.newXPath(); xpath.setNamespaceContext(nsContext); return xpath.evaluate(xpathExpression, node, type); } }