Java XPath Create getXpathExpressionNode(Object xprContext, String xpExpression)

Here you can find the source of getXpathExpressionNode(Object xprContext, String xpExpression)

Description

get Xpath Expression Node

License

Open Source License

Declaration

public static Node getXpathExpressionNode(Object xprContext, String xpExpression)
            throws XPathExpressionException 

Method Source Code


//package com.java2s;
/*/*from   ww  w.  j  a v  a2 s  . com*/
    
Copyright (c) 2009-2011, AOL Inc.
All rights reserved.
    
This code is licensed under a BSD license.
    
Howard Uman
    
*/

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.Node;

public class Main {
    public static Node getXpathExpressionNode(Object xprContext, String xpExpression)
            throws XPathExpressionException {
        XPath xpath = XPathFactory.newInstance().newXPath();

        XPathExpression xpe = xpath.compile(xpExpression);
        Node node = (Node) xpe.evaluate(xprContext, XPathConstants.NODE);
        return node;
    }
}

Related

  1. getXPathExpression(String expression)
  2. getXPathExpression(String path)
  3. getXPathExpression(String xpath, NamespaceContext namespaceContext)
  4. getXPathExpression(String xpathStr)
  5. getXPathExpression(String xPathString)
  6. getXpathExpressionValue(Object xprContext, String xpExpression)
  7. getXPathExprFromNode(Node node)
  8. getXPathExprFromNode(Node node)
  9. getXPathFactory()