0
我使用到了SimplePie解析不同的RSS提要,將它們傳遞給Smarty的模板,我需要從每個項目行,在這個例子中讀取返回屬性:NEWSX和了SimplePie屬性get_item_tags
<source url="http://whatever.url/"><![CDATA[NEWSX]]></source>
我發現get_item_tags方法將選擇使用以下內容的行和屬性:
$newssource = $item->get_item_tags('','source');
這是我的問題。我不知道如何對各源極連接到一個項目使用以下代碼時(使得基本上我可以沿着通常的標題,鏈接,描述每個時間等顯示不同的源元件):
$RSS = array();
foreach($items as $item){
$feed = $item->get_feed();
$tmp=array();
$newssource = $item->get_item_tags('','source');
echo $newssource[0]["data"];
if ($feed){
if ($enclosure = $item->get_enclosure()){
$tmp['title'] = $item->get_title();
$tmp['permalink'] = $item->get_permalink();
$tmp['thumbnail'] = $enclosure->get_thumbnail();
$tmp['description'] = $enclosure->get_description();
$tmp['image'] = $enclosure->get_link();
}
$tmp['date'] = $item->get_date('j M Y');
$tmp['content'] = $item->get_content();
$tmp['title'] = $item->get_title();
$tmp['link'] = $item->get_link();
$tmp['description'] = $item->get_description();
array_push($RSS, $tmp);
}
}
可以這樣做嗎?預先感謝任何幫助或建議。