CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   XML (http://www.codingforums.com/forumdisplay.php?f=3)
-   -   How do i display this xml file within a html page? (http://www.codingforums.com/showthread.php?t=280030)

Cyantyst 10-29-2012 07:58 PM

How do i display this xml file within a html page?
 
<?xml version="1.0" encoding="utf-8"?>

<people>
<person name="Fatboy Slim" bgcolor="78A615" photo="dj1.jpg">
<desc>12345</desc>
<links><![CDATA[description here. Check out this link for more www.fatboyslim.com]]></links>
</person>

<person name="Deadmau5" bgcolor="000000" photo="dj2.jpg">
<desc>12345</desc>
<links><![CDATA[www.deadmau5.com]]></links>
</person>

<person name="Skrillex" bgcolor="374B9F" photo="dj3.jpg">
<desc>12345</desc>
<links><![CDATA[www.skrillex.com]]></links>
</person>

</people>

sunfighter 10-30-2012 12:36 AM

Code:

<?php
$xml = simplexml_load_file("People.xml");  // I made your code into a file named People.xml

$i = 0;
foreach ($xml as $person[])
{
        echo $person[$i]->attributes()->name . "<br />";
        echo $person[$i]->attributes()->bgcolor . "<br />";
        echo $person[$i]->attributes()->photo . "<br />";
        echo $person[$i]->desc . "<br />";
        echo $person[$i]->links . "<br />";
        $i++;
        echo '===================================<br />';
}
?>



All times are GMT +1. The time now is 06:54 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.