Java tutorial
//package com.java2s; //License from project: Common Public License import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { public static XPathExpression allKeyDefs; public static NodeList getKeyDefinitions(Element mapElem) { NodeList resultNl = null; try { resultNl = (NodeList) allKeyDefs.evaluate(mapElem, XPathConstants.NODESET); } catch (XPathExpressionException e) { throw new RuntimeException("Unexpected exception evaluating XPath expression " + allKeyDefs.toString(), e); } return resultNl; } }