![JAR search and dependency download from the Maven repository](/logo.png)
it.svario.xpathapi.jaxp.package-info Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xpathapi-jaxp Show documentation
Show all versions of xpathapi-jaxp Show documentation
Select XML nodes using XPath and a single line of Java code
The newest version!
// This is free software released into the public domain (CC0 license).
/**
* Select XML nodes using XPath and a single line of Java code.
*
*
* XPathAPI offers simple methods to select nodes on XML document trees
* using XPath expressions.
*
*
* The XPathAPI way to select all the nodes that match the XPath
* {@code //friend[@status='best']} is:
*
*
* NodeList bestFriends = XPathAPI.selectNodeList(doc, "//friend[@status='best']");
*
*
*
* That single line is equivalent to this longer and more complex piece of
* code:
*
*
* XPathFactory xpathFactory = XPathFactory.newInstance();
* XPath xpath = xpathFactory.newXPath();
*
* XPathExpression xpathExpr = xpath.compile("//friend[@status='best']");
*
* NodeList bestFriends = (NodeList) xpathExpr.evaluate(contextNode, XPathConstants.NODESET);
*
*
*
* XPathAPI is easier to use but is slower than ad-hoc optimized code,
* especially when multiple XPath expressions are to be evaluated on the same
* big XML document. You should use XPathAPI in non-time-critical code paths
* or for fast prototyping.
*/
package it.svario.xpathapi.jaxp;
© 2015 - 2025 Weber Informatics LLC | Privacy Policy