public class XPathAPI extends Object
NOTE: In particular, each call to this method will create a new XPathContext, a new DTMManager... and thus a new DTM. That's very safe, since it guarantees that you're always processing against a fully up-to-date view of your document. But it's also portentially very expensive, since you're rebuilding the DTM every time. You should consider using an instance of CachedXPathAPI rather than these static methods.
| Constructor and Description |
|---|
XPathAPI() |
| Modifier and Type | Method and Description |
|---|---|
static XObject |
eval(Node contextNode,
String str)
Evaluate XPath string to an XObject.
|
static XObject |
eval(Node contextNode,
String str,
Node namespaceNode)
Evaluate XPath string to an XObject.
|
static XObject |
eval(Node contextNode,
String str,
PrefixResolver prefixResolver)
Evaluate XPath string to an XObject.
|
static org.w3c.dom.traversal.NodeIterator |
selectNodeIterator(Node contextNode,
String str)
Use an XPath string to select a nodelist.
|
static org.w3c.dom.traversal.NodeIterator |
selectNodeIterator(Node contextNode,
String str,
Node namespaceNode)
Use an XPath string to select a nodelist.
|
static NodeList |
selectNodeList(Node contextNode,
String str)
Use an XPath string to select a nodelist.
|
static NodeList |
selectNodeList(Node contextNode,
String str,
Node namespaceNode)
Use an XPath string to select a nodelist.
|
static Node |
selectSingleNode(Node contextNode,
String str)
Use an XPath string to select a single node.
|
static Node |
selectSingleNode(Node contextNode,
String str,
Node namespaceNode)
Use an XPath string to select a single node.
|
public static Node selectSingleNode(Node contextNode, String str) throws TransformerException
contextNode - The node to start searching from.str - A valid XPath string.TransformerException - in case of errorpublic static Node selectSingleNode(Node contextNode, String str, Node namespaceNode) throws TransformerException
contextNode - The node to start searching from.str - A valid XPath string.namespaceNode - The node from which prefixes in the XPath will be resolved to namespaces.TransformerException - in case of errorpublic static org.w3c.dom.traversal.NodeIterator selectNodeIterator(Node contextNode, String str) throws TransformerException
contextNode - The node to start searching from.str - A valid XPath string.TransformerException - in case of errorpublic static org.w3c.dom.traversal.NodeIterator selectNodeIterator(Node contextNode, String str, Node namespaceNode) throws TransformerException
contextNode - The node to start searching from.str - A valid XPath string.namespaceNode - The node from which prefixes in the XPath will be resolved to namespaces.TransformerException - in case of errorpublic static NodeList selectNodeList(Node contextNode, String str) throws TransformerException
contextNode - The node to start searching from.str - A valid XPath string.TransformerException - in case of errorpublic static NodeList selectNodeList(Node contextNode, String str, Node namespaceNode) throws TransformerException
contextNode - The node to start searching from.str - A valid XPath string.namespaceNode - The node from which prefixes in the XPath will be resolved to namespaces.TransformerException - in case of errorpublic static XObject eval(Node contextNode, String str) throws TransformerException
contextNode - The node to start searching from.str - A valid XPath string.TransformerException - in case of errorXObject,
XBoolean,
XNumber,
XStringpublic static XObject eval(Node contextNode, String str, Node namespaceNode) throws TransformerException
contextNode - The node to start searching from.str - A valid XPath string.namespaceNode - The node from which prefixes in the XPath will be resolved to namespaces.TransformerException - in case of errorXObject,
XBoolean,
XNumber,
XStringpublic static XObject eval(Node contextNode, String str, PrefixResolver prefixResolver) throws TransformerException
contextNode - The node to start searching from.str - A valid XPath string.prefixResolver - Will be called if the parser encounters namespace prefixes, to resolve
the prefixes to URLs.TransformerException - in case of errorXObject,
XBoolean,
XNumber,
XStringCopyright © 2022–2023 HtmlUnit. All rights reserved.