Jump to content

help echoing element using simplexml


osaka73

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.