Package org.htmlunit.html.xpath
Class XPathHelper
- java.lang.Object
-
- org.htmlunit.html.xpath.XPathHelper
-
public final class XPathHelper extends java.lang.Object
Collection of XPath utility methods.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.ThreadLocal<java.lang.Boolean>
PROCESS_XPATH_
-
Constructor Summary
Constructors Modifier Constructor Description private
XPathHelper()
Private to avoid instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static org.htmlunit.xpath.objects.XObject
evaluateXPath(DomNode contextNode, java.lang.String str, org.htmlunit.xpath.xml.utils.PrefixResolver prefixResolver)
Evaluates an XPath expression to an XObject.static <T> java.util.List<T>
getByXPath(DomNode node, java.lang.String xpathExpr, org.htmlunit.xpath.xml.utils.PrefixResolver resolver)
Evaluates an XPath expression from the specified node, returning the resultant nodes.static boolean
isProcessingXPath()
Returns whether the thread is currently evaluating XPath expression or no.
-
-
-
Method Detail
-
getByXPath
public static <T> java.util.List<T> getByXPath(DomNode node, java.lang.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, java.lang.String str, org.htmlunit.xpath.xml.utils.PrefixResolver prefixResolver) throws javax.xml.transform.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:
javax.xml.transform.TransformerException
- if a syntax or other error occurs
-
-