note 11780 added to xpath_eval
| From: | pking at hoovers dot com | Date: | Tue, 06 Mar 2001 22:22:25 +0000 |
| Subject: | note 11780 added to xpath_eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-11972@lists.php.net to get a copy of this message | ||
This is a very (very) minor point, but there is a comma missing in the function definition for
xpath_eval. This being my first experience with xpath, I thought "object xpath context"
was refering to a single parameter produced by a previous call to xpath_new_context(). Then I
couldn't see where you would add the query (which is actually the context parameter)
So the proper definition should be
array xpath_eval (object xpath, context)
Additionally an example would be nice. I found one from a post to phpbuilder.com:
-------------------------------
http://www.phpbuilder.com/annotate/message.php3?id=1002772
-------------------------------
Message # 1002772:
Date: 01/02/01 06:40
By: Luis Argerich
Subject: new DOM features im 4.0.4
Just wanted to add that PHP 4.0.4 has improved DOM support including Xpath and
Xpointer support:
Try this:
$xml='SOME XML ....';
$doc=xmldoc($xml);
$ctx=xpath_new_context($doc);
$foo=xpath_eval($ctx,"//title");
print_r($foo);
It returns an object that contains a property called Nodeset with an array of DomNodes with the
result of the Xpath expression. print_r($foo) to see the full structure.
4.0.4 has also added Xpointer support, so with Xpath and Xpointer support we can really do a lot of
things from PHP to XML files.
Luis.
http://www.php.net/manual/en/function.xpath_eval.php