Java tutorial
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Document; import javax.xml.namespace.QName; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; public class Main { public static Boolean selectBoolean(Document xmlDocument, String expression) throws XPathExpressionException { return (Boolean) selectObject(xmlDocument, expression, XPathConstants.BOOLEAN); } public static Object selectObject(Document xmlDocument, String expression, QName returnType) throws XPathExpressionException { XPath xPath = XPathFactory.newInstance().newXPath(); return xPath.compile(expression).evaluate(xmlDocument, returnType); } }