Java Utililty Methods XPath Create

List of utility methods to do XPath Create

Description

The list of methods to do XPath Create are organized into topic(s).

Method

XPathnewXPath()
Create an XPath instance using JVM defaults.
return xPathFactory.newXPath();
XPathExpressionnewXpathExpression(final XPath xpath, final String expression)
new Xpath Expression
try {
    return xpath.compile(expression);
} catch (final Exception e) {
    throw new IllegalStateException(e.getMessage(), e);
XPathFactorynewXPathFactory()
new X Path Factory
factoryLock.lock();
try {
    return XPathFactory.newInstance();
} finally {
    factoryLock.unlock();
XPathxPath()
x Path
return XPATH_POOL.get();
XPathxpath()
Returns a new instance of XPath, which is not thread safe and not reentrant.
return XPathFactory.newInstance().newXPath();
XPathExpressionxpath(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);
Stringxpath(String xml, String xpath)
xpath
XPath xp = XPathFactory.newInstance().newXPath();
Document doc = parse(xml);
return xp.evaluate(xpath, doc.getDocumentElement());
XPathExpressionxPath(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);
NodexpathNode(Node node, String xpath)
xpath Node
return (Node) expr(xpath).evaluate(node, XPathConstants.NODE);
NodeListxpathNodes(Node node, String expression)
xpath Nodes
return xpathNodes(node, expression, null);