Java XPath Select xpathToNode(Document document, String xpathExpression)

Here you can find the source of xpathToNode(Document document, String xpathExpression)

Description

xpath To Node

License

Open Source License

Declaration

public static Node xpathToNode(Document document, String xpathExpression) throws XPathExpressionException 

Method Source Code


//package com.java2s;
import org.w3c.dom.*;

import javax.xml.xpath.*;

public class Main {
    public static Node xpathToNode(Document document, String xpathExpression) throws XPathExpressionException {
        XPath xpath = createXPath();
        return (Node) xpath.evaluate(xpathExpression, document, XPathConstants.NODE);
    }/* w  ww.j a v  a 2 s .com*/

    private static XPath createXPath() {
        return XPathFactory.newInstance().newXPath();
    }
}

Related

  1. XPathAPI_selectNodeList(Document doc, String xpath, Node namespaceNode)
  2. xpathNode(String expr, Document doc)
  3. xpathNodeList(String expr, Document doc)
  4. xpathOrNull(Document doc, String xp)
  5. xpathString(String expr, Document doc)