klyn.io.xml.xpath.DOMXPathEvaluator.selectNodes
method
public selectNodes(expression as String, contextNode as Node, resolver as XPathNSResolver = null) as NodeList throws XPathException, DOMException:
Description

Evaluates an XPath expression and returns the matching nodes as a DOM NodeList.

This is a Klyn convenience method. The standard DOM XPath API still uses evaluate(...) and XPathResult.

Parameters
  • expression XPath expression selecting nodes.
  • contextNode Context node.
  • resolver Namespace resolver, or `null`.
Returns

Matching nodes in document order.

Throws
  • XPathException if the expression cannot be converted to a node set.
  • DOMException if the context node is invalid.
Example
nodes = DOMXPathEvaluator().selectNodes("/Spies/Spy", document)
print(nodes.length)