0
我目前正在顯示RSS源,並且我正在抓取每篇文章的標題,鏈接和日期。我也想抓住媒體:每篇文章的縮略圖。這裏是我用來檢索RSS提要的PHP代碼。顯示來自RSS源的縮略圖
<?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(' & ', ' & ', $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>';
}
?>
RSS源,我顯示爲:http://www.avfc.co.uk/rss/ptv/page/CustomArticleIndex/0,,10265~2282152,00.xml
我不是PHP是很好,所以沒有任何人知道我怎麼能去這樣做?謝謝。
不工作,說:「致命錯誤呼叫到一個非對象的成員函數的getAttribute()」 – warnerr
啊該死,對不起,這是不可能的,我對此進行測試,在此時此刻。現在就試試? – mblitz
仍然沒有工作,得到了錯誤信息'嘗試獲取非對象的屬性'和'致命錯誤:調用' – warnerr