Java XPath Evaluate xpathEvalNodes(String expr, Object e)

Here you can find the source of xpathEvalNodes(String expr, Object e)

Description

xpath Eval Nodes

License

Open Source License

Declaration

public static NodeList xpathEvalNodes(String expr, Object e) 

Method Source Code

//package com.java2s;

import javax.xml.namespace.QName;

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

import org.w3c.dom.NodeList;

public class Main {
    private final static XPath xpath = XPathFactory.newInstance().newXPath();

    public static NodeList xpathEvalNodes(String expr, Object e) {
        return (NodeList) xpathEval(expr, e, XPathConstants.NODESET);
    }/*ww  w  .  ja  v a2s.c om*/

    public static Object xpathEval(String expr, Object e, QName type) {
        try {
            return xpath.evaluate(expr, e, type);
        } catch (Exception exc) {
            throw new RuntimeException("Cannot evaluate xpath expression.", exc);
        }
    }
}

Related

  1. findNodeAndGetXPath(String qName, String fileName)
  2. getNodesListXpath(final String xPathS, final Node node, final String nsuri, final String pre, final QName returnType)
  3. parseVariable(Node contextNode, String xPathString)
  4. xPath(final Node aNode, final String anXPath, final QName aQName)
  5. xpathEvalElements(String expr, Object e)