Java XPath Evaluate evalXpath(String xpath, Object item)

Here you can find the source of evalXpath(String xpath, Object item)

Description

eval Xpath

License

Open Source License

Declaration

public static NodeList evalXpath(String xpath, Object item) throws XPathExpressionException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

import org.w3c.dom.NodeList;

public class Main {
    public static NodeList evalXpath(String xpath, Object item) throws XPathExpressionException {
        XPath xp = XPathFactory.newInstance().newXPath();
        XPathExpression expr = xp.compile(xpath);
        return (NodeList) expr.evaluate(item, XPathConstants.NODESET);
    }/*from w  w w.j a v a  2 s.c o  m*/
}

Related

  1. evaluateXPathQuery(Document doc, NamespaceContext context, String xPathQuery)
  2. evalXPath(Node d, String expr, QName returnType)
  3. evalXPath(Node node, String xPath)
  4. evalXPath(String expression, Object item, Class type)
  5. evalXPath(String path, Document doc)
  6. evalXPathAsString(Object item, String xpath, XPathFactory factory)
  7. evalXPathAsStringList(Object item, String xpath, XPathFactory factory, boolean includeDuplicates)
  8. executeXPath(Document dom, String xpath, QName returnType)
  9. executeXPathExpression(Document document, String expression)