List of utility methods to do XPath Create
XPath | newXPath() Create an XPath instance using JVM defaults. return xPathFactory.newXPath();
|
XPathExpression | newXpathExpression(final XPath xpath, final String expression) new Xpath Expression try { return xpath.compile(expression); } catch (final Exception e) { throw new IllegalStateException(e.getMessage(), e); |
XPathFactory | newXPathFactory() new X Path Factory factoryLock.lock(); try { return XPathFactory.newInstance(); } finally { factoryLock.unlock(); |
XPath | xPath() x Path return XPATH_POOL.get();
|
XPath | xpath() Returns a new instance of XPath, which is not thread safe and not reentrant. return XPathFactory.newInstance().newXPath();
|
XPathExpression | xpath(String expression) Builds an XPath. if (xPath == null) xPath = XPathFactory.newInstance().newXPath(); try { return xPath.compile(expression); } catch (XPathExpressionException e) { throw new AssertionError("Error initializing XPath instance for '" + expression + "': " + e); |
String | xpath(String xml, String xpath) xpath XPath xp = XPathFactory.newInstance().newXPath();
Document doc = parse(xml);
return xp.evaluate(xpath, doc.getDocumentElement());
|
XPathExpression | xPath(String xPath) Creates an xPath expression XPathFactory xPathFactory = XPathFactory.newInstance(); XPath xPathInstance = xPathFactory.newXPath(); try { return xPathInstance.compile(xPath); } catch (XPathExpressionException e) { throw new IllegalArgumentException("Invalid xPath: " + xPath, e); |
Node | xpathNode(Node node, String xpath) xpath Node return (Node) expr(xpath).evaluate(node, XPathConstants.NODE);
|
NodeList | xpathNodes(Node node, String expression) xpath Nodes return xpathNodes(node, expression, null);
|