Re: XPath expressions that return scalar value

From: Date: Thu, 23 Sep 2004 20:04:03 +0000
Subject: Re: XPath expressions that return scalar value
References: 1  Groups: php.xml.dev 
Request: Send a blank email to php-xml-dev+get-462@lists.php.net to get a copy of this message
Hi On 23.9.2004 22:01 Uhr, Jirka Kosek wrote:
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:
We had this discussion already and Yes, it is planned for 5.1. chregu
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
-- christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 http://www.bitflux.ch | chregu@bitflux.ch | gnupg-keyid 0x5CE1DECB

« previous php.xml.dev (#462) next »