Jump to content

[SOLVED] Simplexml read xml


rcmn

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.