Reputation: 55
Good, again I ask your help, I have an xml document (http://inlivefm.6te.net/AirPlayHistory.xml) which provides the name of songs played.
What I'm trying is to remove the information from xml with php echo, I realized a php code but must be wrong, because it gives me nothing so I came to ask your help in solving this problem.
<?php
$xml = simplexml_load_file("http://inlivefm.6te.net/AirPlayHistory.xml");
print $xml->Event->Song['title'];
echo '';
?>
<?php
$xml = simplexml_load_file("http://inlivefm.6te.net/AirPlayHistory.xml");
print $xml->Event->Song->Artist['name'];
echo '';
?>
Someone I can help?
Thank you before too.
Upvotes: 0
Views: 113
Reputation: 26153
simplexml does not see root element. Write it so:
$xml = simplexml_load_file("http://inlivefm.6te.net/AirPlayHistory.xml");
foreach($xml->Song as $item)
echo $item->Artist['name'] . " - " . $item['title'] ."<br>";
Upvotes: 1