Tuesday, July 16, 2013

Reading Xml in PHP using SimpleXML

suppose you have an xml file "sample.xml" on your server with the following content:

<sample index="1" value="0.3" />
<sample index="2" value="0.332" />
<sample index="3" value="0.83" />
<sample index="4" value="0.23" />

The following codes will transform the above xml file into a html table using SimpleXML:

echo "<table>";
foreach($xml->children() as $child)
        echo "<tr><td>".$index."</td><td>".$val."</td></tr>";
echo "</table>";

1 comment:

  1. Thanks for such a great article here. I was searching for something like this for quite a long time and at last I’ve found it on your blog. It was definitely interesting for me to read about their market situation nowadays.
    Best Dot Net Training Institute in Chennai
    Best Software Testing Training Institute in Chennai With Placement
    Java Certification in Chennai
    PHP Training Institute in Chennai