Package org.htmlunit.html.xpath
Class XPathHelper
java.lang.Object
org.htmlunit.html.xpath.XPathHelper
Collection of XPath utility methods.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static org.htmlunit.xpath.objects.XObjectevaluateXPath(DomNode contextNode, String str, org.htmlunit.xpath.xml.utils.PrefixResolver prefixResolver) Evaluates an XPath expression to an XObject.static <T> List<T> getByXPath(DomNode node, String xpathExpr, org.htmlunit.xpath.xml.utils.PrefixResolver resolver) Evaluates an XPath expression from the specified node, returning the resultant nodes.static booleanReturns whether the thread is currently evaluating XPath expression or no.
-
Field Details
-
PROCESS_XPATH_
-
-
Constructor Details
-
XPathHelper
private XPathHelper()Private to avoid instantiation.
-
-
Method Details
-
getByXPath
public static <T> List<T> getByXPath(DomNode node, String xpathExpr, org.htmlunit.xpath.xml.utils.PrefixResolver resolver) Evaluates an XPath expression from the specified node, returning the resultant nodes.- Type Parameters:
T- the type class- Parameters:
node- the node to start searching fromxpathExpr- the XPath expressionresolver- the prefix resolver to use for resolving namespace prefixes, or null- Returns:
- the list of objects found
-
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
-
evaluateXPath
private static org.htmlunit.xpath.objects.XObject evaluateXPath(DomNode contextNode, String str, org.htmlunit.xpath.xml.utils.PrefixResolver prefixResolver) throws TransformerException Evaluates an XPath expression to an XObject.- Parameters:
contextNode- the node to start searching fromstr- a valid XPath stringprefixResolver- prefix resolver to use for resolving namespace prefixes, or null- Returns:
- an XObject, which can be used to obtain a string, number, nodelist, etc (should never be
null) - Throws:
TransformerException- if a syntax or other error occurs
-