Java XPath Select selectSingleNode(final Node node, final String xPath)

Here you can find the source of selectSingleNode(final Node node, final String xPath)

Description

select Single Node

License

Apache License

Declaration

public static Node selectSingleNode(final Node node, final String xPath) throws XPathExpressionException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.Node;

public class Main {
    private static XPathFactory _xpf = XPathFactory.newInstance();

    public static Node selectSingleNode(final Node node, final String xPath) throws XPathExpressionException {
        return (Node) _xpf.newXPath().evaluate(xPath, node, XPathConstants.NODE);
    }/*from  w w  w .  j a va  2  s. co  m*/
}

Related

  1. selectNodes(String xpath, Object node)
  2. selectNodes(String xpath, Object node)
  3. selectNodesViaXPath(XPath xPath, Node startingNode, String xPathExpression)
  4. selectNodeText(Node node, String expression)
  5. selectSingleElement(Element element, String xpathExpression)
  6. selectSingleNode(final Node sourceNode, final String xPathExpression)
  7. selectSingleNode(Node node, String xpath, NamespaceContext context)
  8. selectString(String xpath, Object node)
  9. selectStrings(String xpath, Object node)