Php 显示RSS源中的缩略图

Php 显示RSS源中的缩略图,php,rss,Php,Rss,我目前正在显示一个RSS提要,我正在抓取每篇文章的标题、链接和日期。我还想抓住媒体:每篇文章的缩略图。下面是我用来检索RSS提要的PHP代码 <?php $rss = new DOMDocument(); $rss->load('http://www.avfc.co.uk/rss/ptv/page/CustomArticleIndex/0,,10265~2282152,00.xml');

我目前正在显示一个RSS提要,我正在抓取每篇文章的标题、链接和日期。我还想抓住媒体:每篇文章的缩略图。下面是我用来检索RSS提要的PHP代码

<?php
                $rss = new DOMDocument();
                $rss->load('http://www.avfc.co.uk/rss/ptv/page/CustomArticleIndex/0,,10265~2282152,00.xml');
                $feed = array();



                foreach ($rss->getElementsByTagName('item') as $node) {
                $item = array ( 
                'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
                'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
                'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,

                 );
                array_push($feed, $item);
                 }
                 $limit = 2;
                for($x=0;$x<$limit;$x++) {
                 $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
                $link = $feed[$x]['link'];
                $date = date('l F d, Y', strtotime($feed[$x]['date']));


                echo '<div id="feed"><a target="_blank" href="'.$link.'" title="'.$title.' ">'.$title.'</a><br />';
                echo '<a class="date">Posted on '.$date.'</a></div>';



                 }
                ?>
试试看:

$thumb = $node->getElementsByTagName('media:thumbnail')->item(0)->attributes->getNamedItem('url')->nodeValue;

“对非对象上的成员函数getAttribute()的致命错误调用”啊,天哪,抱歉,我现在无法测试它。现在试试?仍然不起作用,收到错误消息“正在尝试获取中的非对象的属性”和“致命错误:对中的非对象调用成员函数getNamedItem()”,我无法进一步帮助您,但我认为我们走对了方向。继续并
print\r($node->getElementsByTagName('media:缩略图')->项(0)->属性)
并查找一个可能具有您正在查找的值的属性。这给了我一个错误,哈哈,但不用担心,谢谢您到目前为止的帮助