Parsing/Open XML document in echo

249 views Asked by At

I have a radio automation software (RadioBOSS) and I wish I could get artist information (MILKY CHANCE) and Song Title (STOLEN DANCE) through your xml document that this is (http://inlivefm.6te.net/nowplaying2.xml) with the help of PHP echo, but I am not able to obtain this information.

I present the project / PHP code to see if they can detect my fault.

<?php
$x = simplexml_load_file('http://inlivefm.6te.net/nowplaying2.xml');
echo '<font color="#d81c1c" face="Oswald" size="4px" style="display:inline">';
echo $x->PLAYER[0]->TITLE[0];
echo ' - ';
echo '</font>';
?>

I tried to analyze through a your link: How to display info if a tag value is X

I tried to test from the explanation that is in this link but without success, so I came to ask for your help.

1

There are 1 answers

0
Ugur On

The information is presented in the attributes in the xml you provided. So you have to read the attributes of the element.

You can achieve your goal using the php code below.

$xml = simplexml_load_file('http://inlivefm.6te.net/nowplaying2.xml');

echo '<font color="#d81c1c" face="Oswald" size="4px" style="display:inline">';
echo $xml->TRACK["ARTIST"];
echo ' - ';
echo $xml->TRACK["TITLE"];
echo '</font>';

It would be very helpful to check the SimpleXML documentation while dealing issues like that. http://php.net/manual/en/book.simplexml.php