note 23246 deleted from function.xpath-eval by dams
| From: | dams@php.net | Date: | Sat, 27 Jul 2002 23:21:18 +0000 |
| Subject: | note 23246 deleted from function.xpath-eval by dams | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-33731@lists.php.net to get a copy of this message | ||
From php > 4.0.7 this function has a optional third argument: a context node object. The
signature reads:
array xpath_eval ( object context, string xpath [, object context_node] )
It allows you to do relative searches like this:
---- XML ----
<doc>
<section>
<title>My title!</title>
</section>
</doc>
---- CODE ----
$xml = '....';
$dom = domxml_open_mem($xml);
$ctx = xpath_new_context($dom);
$nodes = xpath_eval($ctx, '//section');
# we have a list with all section element objects
$node = $nodes->nodeset[0];
$nodes = xpath_eval($ctx, 'title');
# we have a list of all title element objects that are a child of the first section element
-- ralphm