Module org.htmlunit

Class XPathHelper

java.lang.Object
org.htmlunit.html.xpath.XPathHelper

public final class XPathHelper extends Object
Collection of XPath utility methods.
Author:
Ahmed Ashour, Chuck Dumont, Ronald Brill
  • Method Details

    • getByXPath

      public static <T> List<T> getByXPath(DomNode contextNode, String xpathExpr, org.htmlunit.xpath.xml.utils.PrefixResolver prefixResolver)
      Evaluates an XPath expression from the specified node, returning the resultant nodes.
      Type Parameters:
      T - the type class
      Parameters:
      contextNode - the node to start searching from
      xpathExpr - the XPath expression
      prefixResolver - the prefix resolver to use for resolving namespace prefixes, or null
      Returns:
      the list of objects found
    • getByXPath

      public static <T> List<T> getByXPath(Node node, XPathAdapter xpath, org.htmlunit.xpath.xml.utils.PrefixResolver prefixResolver) throws TransformerException
      Type Parameters:
      T - the type of nodes expected
      Parameters:
      node - the start node
      xpath - the XPathAdapter to search for
      prefixResolver - the PrefixResolver to be used
      Returns:
      a list of nodes matching the given xpath
      Throws:
      TransformerException - in case of error
    • isProcessingXPath

      public static boolean isProcessingXPath()
      Returns whether the thread is currently evaluating XPath expression or no.
      Returns:
      whether the thread is currently evaluating XPath expression or no