I am just learning some php and I am having an issue. I am trying to read through an xml doc and create web links. This is the code I am trying to use.
And here is what the xml will look like.Code:<?php
$file = "includes/links.xml";
$xml = simplexml_load_file($file) or die ("Unable to load XML file!");
echo "loaded";
if($xml)
{
foreach($xml->link->links as $link)
{
$url = $link->linkurl;
$sitename = $link->sitename;
echo '<a href="'.$url.'">'.$sitename.'</a><br />';
}
}
?>
Ideally I would like to figure out how to read the category and then write the urls that fit the category. Right now it is loading but I am not getting any results.. I am quite sure the syntax is off so I am asking for some help.Code:<links>
<link>
<category>News</category>
<linkurl>http://www.cnn.com</linkurl>
<sitename>CNN</sitename>
</link>
<link>
<category>Tech</category>
<linkurl>http://www.google.com</linkurl>
<sitename>Google</sitename>
</link>
</links>
Thanks
