List of utility methods to do XPath Evaluate
String | evaluateXPath(Node node, String xPath) evaluate X Path int currentSearchIndex = 0; while (currentSearchIndex < xPath.length()) { int endingIndex = xPath.indexOf("/", currentSearchIndex); String noderNameFromXPath = null; if (endingIndex == -1) { noderNameFromXPath = xPath.substring(currentSearchIndex); } else { noderNameFromXPath = xPath.substring(currentSearchIndex, endingIndex); ... |
T | evaluateXpath(String expression, Document document, QName dataType) evaluate Xpath try { XPath xpath = createXPath(); XPathExpression compiledExpression = xpath.compile(expression); return (T) compiledExpression.evaluate(document, dataType); } catch (XPathExpressionException e) { throw new IllegalArgumentException("Cannot evaluate XPath expression '" + expression + "'"); |
Object | evaluateXpath(String expression, Object node, QName returnType, NamespaceContext nsContext) evaluate Xpath XPathFactory xpathFactory = XPathFactory.newInstance(); XPath xpath = xpathFactory.newXPath(); if (nsContext != null) { xpath.setNamespaceContext(nsContext); return xpath.evaluate(expression, node, returnType); |
Object | evaluateXPath(String path, Node e, QName type) evaluate X Path try { XPathExpression expr = compiledString.get(path); if (expr == null) { expr = xpath.compile(path); compiledString.put(path, expr); return expr.evaluate(e, type); } catch (XPathExpressionException e1) { ... |
Object | evaluateXPath(String xpath, Object item, QName returnType) evaluate X Path try { return XPathFactory.newInstance().newXPath().compile(xpath).evaluate(item, returnType); } catch (XPathExpressionException e) { throw new IllegalArgumentException(e); |
NodeList | evaluateXPathAsNodeList(String expression, Document document) Returns the XML NodeList matching the given XPath expression. return evaluateXpath(expression, document, XPathConstants.NODESET);
|
boolean | evaluateXPathBool(final Node inNode, final String xpath) evaluate X Path Bool Boolean xPathBool = (Boolean) getNodesListXpath(xpath, inNode, "", "", XPathConstants.BOOLEAN); return xPathBool.booleanValue(); |
Object | evaluateXPathExpr(final File xmlFile, final XPathExpression xPathExpression, final QName returnType) Evaluates the passed XPathExpression against the Document created out of the passed xmlFile and returns the result of the evaluation.
if (xmlFile == null) { throw new IllegalArgumentException("XML file cannot be null"); if (!xmlFile.isFile()) { throw new IllegalArgumentException(xmlFile + " is either missing or not a file"); if (xPathExpression == null) { throw new IllegalArgumentException("XPath expression cannot be null"); ... |
NodeList | evaluateXPathExpr(XPathExpression xpath, Node node) evaluate X Path Expr return (NodeList) xpath.evaluate(node, XPathConstants.NODESET);
|
NodeList | evaluateXPathExpression(final String expression, final Node node) Evaluate XPath expression and return list of nodes. return (NodeList) evaluateXPathExpression(expression, node, XPathConstants.NODESET);
|