List of utility methods to do XPath Evaluate
Object | executeXPath(Document dom, String xpath, QName returnType) execute X Path XPathExpression expr = XPathFactory.newInstance().newXPath().compile(xpath);
return expr.evaluate(dom, returnType);
|
NodeList | executeXPathExpression(Document document, String expression) execute X Path Expression NodeList nodeList = null; XPathFactory xPathfactory = XPathFactory.newInstance(); XPath xpath = xPathfactory.newXPath(); XPathExpression expr; try { expr = xpath.compile(expression); nodeList = (NodeList) expr.evaluate(document, XPathConstants.NODESET); } catch (XPathExpressionException e) { ... |
Object | execXPath(org.w3c.dom.Node node, String pattern, QName xPathConstantsType) exec X Path return XPathFactory.newInstance().newXPath().compile(pattern).evaluate(node, xPathConstantsType);
|
String | findNodeAndGetXPath(String qName, String fileName) find Node And Get X Path return getFullXPath(findNode(qName, fileName));
|
Object | getNodesListXpath(final String xPathS, final Node node, final String nsuri, final String pre, final QName returnType) get Nodes List Xpath Object matches = null; System.setProperty("javax.xml.xpath.XPathFactory:" + XPathConstants.DOM_OBJECT_MODEL, XPATH_FACTORY); XPathFactory xpathFactory = XPathFactory.newInstance(XPathConstants.DOM_OBJECT_MODEL); XPath xpath = xpathFactory.newXPath(); XPathExpression xpe = xpath.compile(xPathS); matches = xpe.evaluate(node, returnType); return matches; |
String | parseVariable(Node contextNode, String xPathString) parse Variable String varName = null;
return varName;
|
T | xPath(final Node aNode, final String anXPath, final QName aQName) x Path return (T) xPath.compile(anXPath).evaluate(aNode, aQName);
|
List | xpathEvalElements(String expr, Object e) xpath Eval Elements NodeList nl = xpathEvalNodes(expr, e); List<Element> res = new ArrayList<Element>(); for (int i = 0; i < nl.getLength(); i++) { res.add((Element) nl.item(i)); return res; |
NodeList | xpathEvalNodes(String expr, Object e) xpath Eval Nodes return (NodeList) xpathEval(expr, e, XPathConstants.NODESET);
|