rcmn Posted August 2, 2007 Share Posted August 2, 2007 I want to read "param" and the entry in it.Something like $xml->info->node->param[0]['name']. But it doesn't work like that and i was wondering if anyone know how i should do it.below the php code i'm using and the xml file to read. PHP: <?php $string = "http://pathto/myxml.xml"; $xml = simplexml_load_file($string); echo "host:<b>".$xml['host']."</b><br>"; /*<--this work*/ echo $xml['timestamp']."<br>";/*<--this work*/ echo "<hr>"; $xml->info->node->param[0]['name'];/*<--this DOESN"T work or any similar syntax*/ ?> XML: <node-status port="1000" host="MYHOSTNODE" timestamp="TIMEWITHHOUR"> <info> <node> <param name="type" value="special"/> <param name="id" value="25486622225"/> <param name="version" value="0.225"/> <param name="up-since" value="sometime"/> <param name="connections" value="1"/> <param name="thread-count" value="5"/> </node> </info> </node-status> Link to comment https://forums.phpfreaks.com/topic/63063-solved-simplexml-read-xml/ Share on other sites More sharing options...
rcmn Posted August 2, 2007 Author Share Posted August 2, 2007 foreach ($xml->info->node[0]->param as $param) { echo $param['name']."<br>"; } Link to comment https://forums.phpfreaks.com/topic/63063-solved-simplexml-read-xml/#findComment-314085 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.