osaka73 Posted March 19, 2011 Share Posted March 19, 2011 Hi, My script is pretty simple: $xml = simplexml_load_file("http://lyrics.wikia.com/api.php?artist={$lyric_artist}&song={$lyric_song}&fmt=xml"); foreach( $xml as $element ) { print_r( $element ); } Of course those $strings are defined. So the output of that is: SimpleXMLElement Object ( [0] => The Beatles ) SimpleXMLElement Object ( [0] => Let It Be ) SimpleXMLElement Object ( [0] => When I find myself in times of trouble Mother Mary comes to me Speaking words of wisdom Let it be And in my hour of darkness She is standing right in front of me Speaking words[...] ) SimpleXMLElement Object ( [0] => http://lyrics.wikia.com/The_Beatles:Let_It_Be ) SimpleXMLElement Object ( [0] => 0 ) SimpleXMLElement Object ( [0] => 20851 ) I want to echo JUST the lyric part: When I find myself in times of trouble Mother Mary comes to me Speaking words of wisdom Let it be And in my hour of darkness She is standing right in front of me Speaking words[...] But I'm clueless, with everything having the Object [0], I'm not sure how to grab the particular part that I want. Can anyone help me out or point me in the right direction? Link to comment https://forums.phpfreaks.com/topic/231052-help-echoing-element-using-simplexml/ Share on other sites More sharing options...
osaka73 Posted March 19, 2011 Author Share Posted March 19, 2011 so it was super easy... I know. $xml = simplexml_load_file("http://lyrics.wikia.com/api.php?artist={$lyric_artist}&song={$lyric_song}&fmt=xml"); $lyric=$xml->lyrics; echo $lyric; I guess that's why they call it simpleXML. Link to comment https://forums.phpfreaks.com/topic/231052-help-echoing-element-using-simplexml/#findComment-1189695 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.