Class XPathAPI


  • public class XPathAPI
    extends Object
    XPathAPI class provides the convenience function for XPath API that is a subset of Xalan XPathAPI but uses JAXP internally.
    • Method Detail

      • selectSingleNode

        public static Node selectSingleNode​(Node doc,
                                            String str)
                                     throws XPathException
        Use an XPath string to select a single node. Namespace prefix is resolved using the document node.
        Parameters:
        doc - The node to start searching from with the embedded context.
        str - XPath string.
        Returns:
        The first node found that matches the XPath, or null.
        Throws:
        XPathException
      • selectSingleNode

        public static Node selectSingleNode​(Node doc,
                                            String str,
                                            Node nsNode)
                                     throws XPathException
        Use an XPath string to select a single node using a provided element namespace.
        Parameters:
        doc - The node to start searching from.
        str - XPath string.
        nsNode - Node where namespace prefix in XPath is resolved from.
        Returns:
        The first node found that matches the XPath, or null.
        Throws:
        XPathException
      • selectSingleNode

        public static Node selectSingleNode​(Node doc,
                                            String str,
                                            NamespaceContext nsctx)
                                     throws XPathException
        Use an XPath string to select a single node using a passed in namespace context.
        Parameters:
        doc - The node to start searching from.
        str - XPath string.
        nsctx - Namespace where the prefix in XPath is resolved from.
        Returns:
        The first node found that matches the XPath, or null.
        Throws:
        XPathException
      • selectNodeList

        public static NodeList selectNodeList​(Node doc,
                                              String str)
                                       throws XPathException
        Use an XPath string to select a nodelist. Namespace prefix is resolved using the document node.
        Parameters:
        doc - The node to start searching from.
        str - XPath string.
        Returns:
        a NodeList of the matched result.
        Throws:
        XPathException
      • selectNodeList

        public static NodeList selectNodeList​(Node doc,
                                              String str,
                                              Node nsNode)
                                       throws XPathException
        Use an XPath string to select a nodelist using a node namespace.
        Parameters:
        doc - The node to start searching from.
        str - XPath string.
        nsNode - Node where namespace prefix in XPath is resolved from.
        Returns:
        a NodeList of the matched result.
        Throws:
        XPathException
      • selectNodeList

        public static NodeList selectNodeList​(Node doc,
                                              String str,
                                              NamespaceContext nsctx)
                                       throws XPathException
        Use an XPath string to select a nodelist Namespace prefix is resolved using the the specified context.
        Parameters:
        doc - The node to start searching from.
        str - XPath string.
        nsctx - Namespace where the prefix in XPath is resolved from.
        Returns:
        a NodeList.
        Throws:
        XPathException