Android XPath Evaluate getElementByXPath(Element e, String xPathExpression)

Here you can find the source of getElementByXPath(Element e, String xPathExpression)

Description

get Element By X Path

License

Open Source License

Declaration

public static Element getElementByXPath(Element e,
            String xPathExpression) throws XPathExpressionException 

Method Source Code

//package com.java2s;
// it under the terms of the GNU Affero General Public License as

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

import org.w3c.dom.Element;

public class Main {
    public static Element getElementByXPath(Element e,
            String xPathExpression) throws XPathExpressionException {
        XPathFactory factory = XPathFactory.newInstance();
        XPath xPath = factory.newXPath();

        return (Element) (xPath.evaluate(xPathExpression, e,
                XPathConstants.NODE));

    }// www.jav a  2 s  .  c o  m
}

Related

  1. asByte(String expression, Node node)
  2. asByteBuffer(String expression, Node node)
  3. asBoolean(String expression, Node node)
  4. evaluateXPath(Node node, String xPath)
  5. evaluateAsString(String expression, Node node)
  6. findXPathNode(Node node, String xPath)
  7. findXPathNodeList(Node node, String xPath)
  8. findChildNodeWithName(Node node, String childName)
  9. getXPathItemText(Document doc, XPath xpath, String query)