XML & PHP

Apple has a nice iTunes RSS feed generator. I want to use its output to make a simple web page with all the latest album releases etc.  I have the following test setup: http://54.88.218.38/test.php. I am running into issues when I try and access the objects/elements (not sure what they are called) that have a “:” in the name. Here is the raw output: https://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/newreleases/sf=143441/limit=50/rss.xml

<itms:artist>  and <itms:coverArt height=”100″ width=”100″> are elements I am trying to access. PHP pukes on the “:” no matter how I try and escape the character.

 

Any suggestions?

*** UPDATE ***

Here is the code with Chris’ suggestions:

 

 

7 Replies to “XML & PHP”

  1. channel->item;

    foreach($album as $a){
    $i++;
    echo $a->title.””;
    echo $a->children(‘itms’, true)->artist.””;
    echo $a->children(‘itms’, true)->coverArt[2];
    ?>

  2. the comments dont like html in them… this is how you echo the artist and cover image

    echo $a->children(‘itms’, true)->artist;
    echo $a->children(‘itms’, true)->coverArt[2];

    1. That worked! Now for the next step. How can I take the album output and do a lookup against the spotify’s API? it doesn’t look like I can just point the simplexml_load_file at their API url…

          1. I search by the artist name, find the crazy uri string that spotify uses and then get all the albums related to the artists uri.

Leave a Reply

Your email address will not be published. Required fields are marked *