XPath expressions that return scalar value
[email protected] (Jirka Kosek) Thu, 23 Sep 2004 22:01:50 +0200
| Newsgroups | php.xml.dev |
|---|---|
| Message-ID | <[email protected]> |
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: [email protected] 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
------------------------------------------------------------------