public class DOMXPathEvaluator extends Object implements XPathEvaluator:
Pure Klyn DOM XPath evaluator.
This class implements the DOM Level 3 XPath API surface and evaluates the XPath 1.0 subset currently supported by the Klyn XML library: location paths, attributes, text(), node(), count, string, number, boolean, name, local-name, contains, not, and simple comparisons.
Unsupported XPath syntax raises XPathException.INVALID_EXPRESSION_ERR instead of returning an approximate result.
@example `klyn import klyn.io.xml.dom import klyn.io.xml.xpath import org.w3c.dom.xpath
document = DOMParser().parseFromFile("test/klyn/io/xml/Spies.xml") evaluator = DOMXPathEvaluator() result = evaluator.evaluate("count(//Spy)", document, null, XPathResult.NUMBER_TYPE, null) print(result.numberValue)
| Modifier and Type | Member | Description |
|---|---|---|
| public | DOMXPathEvaluator | Creates an XPath evaluator. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | createExpressioncreateExpression(expression as String, resolver as XPathNSResolver) as XPathExpression throws XPathException, DOMException: |
Compiles an XPath expression. |
| public | createNSResolvercreateNSResolver(nodeResolver as Node) as XPathNSResolver: |
Creates a namespace resolver backed by a DOM node. |
| public | evaluateevaluate(expression as String, contextNode as Node, resolver as XPathNSResolver, type as Int, result as XPathResult) as XPathResult throws XPathException, DOMException: |
Evaluates an XPath expression. |
| public | selectNodesselectNodes(expression as String, contextNode as Node, resolver as XPathNSResolver = null) as NodeList throws XPathException, DOMException: |
Evaluates an XPath expression and returns the matching nodes as a DOM `NodeList`. |
| public | selectSingleNodeselectSingleNode(expression as String, contextNode as Node, resolver as XPathNSResolver = null) as Node throws XPathException, DOMException: |
Evaluates an XPath expression and returns its first matching node. |