This is the PHP 5 DOMXPath class? It just passes XPath queries to
libxml2, so it should support everything you want. What specifically
are you missing?
-adam
Yes, I mean PHP5 DOMXPath. OK, here's a sample script:
<?php
$xml = <<<XML
<music>
<artist id="1">
<name>The Rolling Stones</name>
<albums>
<title>Exile On Main Street</title>
</albums>
</artist>
<artist id="2">
<name>Aimee Mann</name>
<albums>
<title>I'm With Stupid</title>
<title>Bachelor No. 2</title>
</albums>
</artist>
</music>
XML;
$dom = new DomDocument();
$dom->loadXML($xml);
$xpath = new DomXpath($dom);
var_dump($xpath->query("count(//music/artist)"));
?>
Result of the var_dump (php5.0.0):
object(DOMNodeList)#3 (0) { }
I expected to get a number (2), but Chrisitan told me before that right now query will only return DOMNodeList's. A workaround is to query for the nodes (//music/artist) and then use PHP's count() function, but I was wondering when query will actually return a number instead of a nodelist.