note 21413 added to function.xpath-eval
| From: | a dot n at cerca dot com | Date: | Sun, 12 May 2002 03:16:54 +0000 |
| Subject: | note 21413 added to function.xpath-eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30496@lists.php.net to get a copy of this message | ||
declarations of namespaces are implemented but not documented (v. 4.2.0)
function: xpath_register_ns(xpathctx_handle, namespace_prefix, namespace_uri)
return: true on success, false otherwise
--- XML---
<?xml version="1.0" standalone="yes"?>
<book xmlns:foo="http://www.foo.com/foo">
<author foo:ref="something">
<firstName>Dante</firstName>
<lastName>Alighieri</lastName>
<foo:item>Other</foo:item>
</author>
....
</book>
---- CODE ---
$xml='....';
$doc=xmldoc($xml);
$xpath_ctx=xpath_new_context($doc);
xpath_register_ns($xpath_ctx, 'foo', 'http://foo.com/foo');
//some examples (untested)
$xpath_nodes = xpath_eval($xpath_ctx, "//@foo:ref");
$xpath_nodes = xpath_eval($xpath_ctx, "//author/foo:item");
$xpath_nodes = xpath_eval($xpath_ctx, "/book/author/@foo:ref");
...
--
http://www.php.net/manual/en/function.xpath-eval.php
http://master.php.net/manage/user-notes.php?action=edit+21413
http://master.php.net/manage/user-notes.php?action=delete+21413
http://master.php.net/manage/user-notes.php?action=reject+21413