XPath expressions that return scalar value
| From: | Jirka Kosek | Date: | Thu, 23 Sep 2004 20:01:50 +0000 |
| Subject: | XPath expressions that return scalar value | ||
| Groups: | php.xml.dev | ||
| Request: | Send a blank email to php-xml-dev+get-461@lists.php.net to get a copy of this message | ||
Hi,
DOMXPath->query() method according to documentation returns DOMNodeList() object. But how can I access result of expression that returns just string, number or boolean?
E.g. DOMXPath->query("count(//*)") will return empty node-set from PHP point of view.
Do you plan to add new method, say evaluate, that will be able to return scalar types? Something like:
echo "Total number of element in document: " . $xpath->evaluate("count(//*)");
echo "Title of the first chapter: " . $xpath->evaluate("string(//chapter[1])");
Without such method XPath API in PHP is very limited compared to other XPath API in languages like Java or .NET.
Jirka
--
------------------------------------------------------------------
Jirka Kosek e-mail: jirka@kosek.cz http://www.kosek.cz
------------------------------------------------------------------
Profesionální školení a poradenství v oblasti technologií XML.
Podívejte se na náš nově spuštěný web http://DocBook.cz
------------------------------------------------------------------