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.
<html>
<body>
<?php
$newsongs = simplexml_load_file('https://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/newreleases/sf=143441/limit=50/rss.xml');
echo $newsongs->channel->title; ?> <p> <?
$album = $newsongs->channel->item;
foreach($album as $a){
$i++;
echo $a->title; ?> <p> <?
}
?>
</body>
</html>
Any suggestions?
*** UPDATE ***
Here is the code with Chris’ suggestions:
<?php
$lrgImage = "200x200-75.jpg";
$smlImage = "100x100-75.jpg";
$newsongs = simplexml_load_file('https://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/newreleases/sf=143441/limit=50/rss.xml');
echo $newsongs->channel->title; ?> <p> <?
$album = $newsongs->channel->item;
foreach($album as $a){
$i++;
$aw = $a->children('itms',true)->coverArt[2];
$artwork = str_replace($smlImage, $lrgImage, $aw);
echo "<img src=" . $artwork . ">"; ?> <br> <?
echo "Artist: " . $a->children('itms',true)->artist . " Album: " . $a->children(itms,true)->album; ?> <br> <?
echo "Relase Date: " . $a->children('itms',true)->releasedate; ?> <p> <?
}
?>