note 82986 added to function.simplexml-element-xpath
| From: | canuemail at gmail dot com | Date: | Mon, 05 May 2008 12:05:48 +0000 |
| Subject: | note 82986 added to function.simplexml-element-xpath | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139069@lists.php.net to get a copy of this message | ||
If you want to search multiple values from xml on the behalf or one value then this code can be
helpfull to you.
if there is:
<Record>
<country>Pakistan</country>
<code>+92</code>
<Value>100<Value>
</Record>
then try this one:
$sxe = simplexml_load_file("countries.XML");
foreach($sxe->xpath('//RECORD') as $item) {
$row = simplexml_load_string($item->asXML());
$v = $row->xpath('//country[. ="Pakistan"]');
if($v[0]){
print $item->country;
print $item->code;
print $item->value;
}
}
----
Server IP: 194.153.94.10
Probable Submitter: 203.128.13.110
----
Manual Page -- http://www.php.net/manual/en/function.simplexml-element-xpath.php
Edit -- https://master.php.net/note/edit/82986
Del: integrated -- https://master.php.net/note/delete/82986/integrated
Del: useless -- https://master.php.net/note/delete/82986/useless
Del: bad code -- https://master.php.net/note/delete/82986/bad+code
Del: spam -- https://master.php.net/note/delete/82986/spam
Del: non-english -- https://master.php.net/note/delete/82986/non-english
Del: in docs -- https://master.php.net/note/delete/82986/in+docs
Del: other reasons-- https://master.php.net/note/delete/82986
Reject -- https://master.php.net/note/reject/82986
Search -- https://master.php.net/manage/user-notes.php