Java XPath Select selectNodeIterator(Node nContextNode, String sXPath)

Here you can find the source of selectNodeIterator(Node nContextNode, String sXPath)

Description

Use an XPath string to select a nodelist.

License

Apache License

Parameter

Parameter Description
nContextNode The node to start searching from.
sXPath A valid XPath string.

Exception

Parameter Description
TransformerException an exception

Return

A NodeIterator, should never be null.

Declaration

public static NodeIterator selectNodeIterator(Node nContextNode, String sXPath) throws TransformerException 

Method Source Code

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

import java.lang.reflect.Method;

import javax.xml.transform.TransformerException;

import org.w3c.dom.Node;

import org.w3c.dom.traversal.NodeIterator;

public class Main {
    /** Holds the method for executing the selectNodeIterator method. */
    private static Method s_mSelectNodeIterator;

    /**/*from  ww  w .ja  va  2s.  co m*/
     * Use an XPath string to select a nodelist. XPath namespace prefixes are resolved from the contextNode.
     * 
     * @param nContextNode The node to start searching from.
     * @param sXPath A valid XPath string.
     * @return A NodeIterator, should never be null.
     * @throws TransformerException
     */
    public static NodeIterator selectNodeIterator(Node nContextNode, String sXPath) throws TransformerException {
        try {
            return (NodeIterator) s_mSelectNodeIterator.invoke(null, new Object[] { nContextNode, sXPath });
        } catch (Exception e) {
            throw new TransformerException(e);
        }
    }
}

Related

  1. getValueByXPath(Document document, String xpath)
  2. getValueByXPathAsInt(Document document, String xpath)
  3. getValueFromXPath(Document document, String xpathString)
  4. getXmlElements(Document inXml, String xpath)
  5. selectElements(Element element, String xpathExpression)
  6. selectNodeList(Node contextNode, String expression)
  7. selectNodeList(Node node, String expression)
  8. selectNodes(final Node node, final String xPath)
  9. selectNodes(Node nodeParent, String name)