note 107989 deleted from function.simplexml-load-file by danbrown
| From: | danbrown@php.net | Date: | Thu, 10 May 2012 18:00:21 +0000 |
| Subject: | note 107989 deleted from function.simplexml-load-file by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187701@lists.php.net to get a copy of this message | ||
Note Submitter: julian dot kanini at gmail dot com
----
Recursively analyze full XML (as explained by guego dot ol at ig dot com dot br ... PS. Thanks!)
//Recursive XML Analyzer
function recurseXML($xml, $step)
{
$step++;
foreach($xml as $key0 => $value)
{
$dots="";
for($i=0; $i<=$step; $i++)
$dots.="...";
echo $dots.$step.$dots."[$key0] => $value <br />";
foreach($value->attributes() as $attributeskey0 => $attributesvalue1)
{
echo "________[$attributeskey0] = $attributesvalue1";
}
if($value)
recurseXML($value, $step);
}
}
//Calling
$xml = simplexml_load_file("data.xml");
recurseXML($xml, 0);