select. XPath search for node

$NodeList[^node.select[XPath-query]]

This method returns list of nodes found in the scope of specified
node and satisfying specified XPath-query. If no node was found, empty list will be returned.

Before using prefixes of name spaces in the
query one must define them, see $xdoc.search-namespaces.

Example
$d[^xdoc::create{<?xml version="1.0" encoding="windows-1251" ?>
<document>
    
<t/><t/>
</document>
}]
# result is list of two elements "t"
$list[^d.select[/document/t]]
# iterating through found lists:
# this code will work
# even if query returns no nodes at all
^for[i](0;$list-1){
    $node[$list.$i]
    Name$node.nodeName<br />
    
Type$node.nodeType
<br />
}

In Parser, DOM interface NodeList
is class hash with keys 0, 1, …;

Detailed specification of XPath is available at: http://www.w3.org/TR/xpath



Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 21.09.2007