Re: [PHP-XML-DEV] XPath expressions that return scalar value

[email protected] (Christian Stocker) Thu, 23 Sep 2004 22:04:03 +0200
Newsgroups php.xml.dev
Message-ID <[email protected]>
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  |  [email protected]  |  gnupg-keyid 0x5CE1DECB