dongwo7858 2012-04-13 15:18
浏览 37
已采纳

Zend_Feed访问项 - ATOM

Iam trying to read the "itunes RSS Feed". As far as i know it is ATOM based.

Works fine:

    $feed = $this->getFeed(self::TOP300_PAYED);

    foreach ($feed as $item) {
        echo $item->name;
    }

But i need the following node:

<im:image height="53">
http://a3.mzstatic.com/us/r1000/116/Purple/61/9b/f2/mzl.wyuzxxzw.53x53-50.png
</im:image>

any idea how to access this with zend feed??

  • 写回答

2条回答 默认 最新

  • dongxian3852 2012-04-13 19:44
    关注

    Like any other ATOM feed, you can iterate over it like this:

        $feed = new Zend_Feed_Atom("example.com");
        foreach ($feed as $entry) {
            $xml = $entry->saveXml();
            $xmlObj = simplexml_load_string($xml);
    
            $xmlObj->registerXPathNamespace('im', "example.com");
            $result = $xmlObj->xpath('//im:image');
    
            foreach ($result as $image) {
              echo $image . "
    ";
            }
        }
    

    Note the use of registerXPathNamespace() here, it seems that iTunes uses namespace in their feed, this is the reason why you need to register it first.

    Try this and let me know if it works.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘