note 89953 added to function.simplexml-element-xpath
| From: | jchris dot fillionr at kitware dot com | Date: | Mon, 30 Mar 2009 19:03:47 +0000 |
| Subject: | note 89953 added to function.simplexml-element-xpath | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152625@lists.php.net to get a copy of this message | ||
An other example:
<?php
$string = <<<XML
<a>
<b>
<c>
<d>Apple</d>
<d>Banana</d>
</c>
<e>
<f>Kiwi</f>
</e>
</b>
</a>
XML;
//$string = file_get_contents("test.xml");
$xml = new SimpleXMLElement($string);
/* Search for <a><b><c> */
$result = $xml->xpath('/a/b/c/d');
while(list( , $node) = each($result)) {
echo '/a/b/c/d: ',$node,"\n";
}
/* Relative paths ... : DO NOT WORK */
$result = $xml->xpath('c/d');
while(list( , $node) = each($result)) {
echo 'c/d: ',$node,"\n";
}
/* Relative paths ... : WORK */
$result = $xml->xpath('b/c/d');
while(list( , $node) = each($result)) {
echo 'b/c/d: ',$node,"\n";
}
/* Relative paths ... : WORK */
$result = $xml->xpath('//c/d');
while(list( , $node) = each($result)) {
echo '//c/d: ',$node,"\n";
}
?>
----
Server IP: 208.69.120.35
Probable Submitter: 24.199.146.138
----
Manual Page -- http://www.php.net/manual/en/function.simplexml-element-xpath.php
Edit -- https://master.php.net/note/edit/89953
Del: integrated -- https://master.php.net/note/delete/89953/integrated
Del: useless -- https://master.php.net/note/delete/89953/useless
Del: bad code -- https://master.php.net/note/delete/89953/bad+code
Del: spam -- https://master.php.net/note/delete/89953/spam
Del: non-english -- https://master.php.net/note/delete/89953/non-english
Del: in docs -- https://master.php.net/note/delete/89953/in+docs
Del: other reasons-- https://master.php.net/note/delete/89953
Reject -- https://master.php.net/note/reject/89953
Search -- https://master.php.net/manage/user-notes.php