我想从iTunes排名前100位的RSS获得以下信息,但下面有问题。
function itunes(){
$itunes_feed = "https://itunes.apple.com/au/rss/topsongs/limit=100/explicit=true/xml";
$itunes_feed = file_get_contents($itunes_feed);
$itunes_feed = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $itunes_feed);
$itunes_xml = new SimpleXMLElement($itunes_feed);
$itunes_entry = $itunes_xml->entry;
foreach($itunes_entry as $entry){
// Get the value of the entry ID, by using the 'im' namespace within the <id> attribute
$entry_id['im'] = $entry->id->attributes('im', TRUE);
echo $entry_id['im']['id']."<br>";
//echo $entry_id['artist']."<br>";
}
}我可以从<id im:id="783656917">那里得到身份证
但是,我无法得到以下内容
<im:artist href="https://itunes.apple.com/au/artist/pharrell-williams/id14934728?uo=2">Pharrell Williams</im:artist>我想要Pharrell Williams我试过$entry->id->attributes->im[artist] $entry_id['artist'],甚至$entry_id->artist
但无论我做什么,我都不能让它给我一个艺术家的名字。
发布于 2014-01-30 12:00:30
您需要将对象强制转换为字符串。
$value = (string)($entry->imartist);https://stackoverflow.com/questions/21455859
复制相似问题