How to read image tag from RSS itunes

前端 未结 2 786
一生所求
一生所求 2021-01-14 13:58

I try to read my iTunes RSS. I can read title, even itunes:subtitle but I have problems with the tag image.

FEED:



        
2条回答
  •  灰色年华
    2021-01-14 14:47

    You could use SimpleXML. Because the image element has a namespace prefix (itunes), you have to use the children method to pass the namespace URL, then call the attributes method:

    $feed = simplexml_load_file('http://www.myWeb/rss.xml');
    foreach ($feed->channel as $channel) {
      $ns_itunes = $channel->children('http://www.itunes.com/dtds/podcast-1.0.dtd');
      echo $ns_itunes->image->attributes();
    }
    

提交回复
热议问题