DOMXPathEvaluator
class in package klyn.io.xml.xpath

    public class DOMXPathEvaluator extends Object implements XPathEvaluator:

Object
└ DOMXPathEvaluator
All Implemented Interfaces: 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)

Properties inherited from Object: type
Constructors

Modifier and Type | Member | Description
--- | --- | ---
public | DOMXPathEvaluator `DOMXPathEvaluator():` | Creates an XPath evaluator.

Methods

Modifier and Type | Member | Description
--- | --- | ---
public | createExpression `createExpression(expression as String, resolver as XPathNSResolver) as XPathExpression throws XPathException, DOMException:` | Compiles an XPath expression.
public | createNSResolver `createNSResolver(nodeResolver as Node) as XPathNSResolver:` | Creates a namespace resolver backed by a DOM node.
public | evaluate `evaluate(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 | selectNodes `selectNodes(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 | selectSingleNode `selectSingleNode(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.

Methods inherited from Object: fromJson, toDict, toJson, toString, toXml
Methods inherited from XPathEvaluator: createExpression, createNSResolver, evaluate