1
我有以下rss格式,並且我無法彈出'content:encoded'值。如何從RSS獲取具有自定義名稱的元素?
<item>
<title>some title</title>
<link>some link</link>
<pubDate>Sat, 07 Apr 2012 5:07:00 -0700</pubDate>
<content:encoded><![CDATA[this value]]></content:encoded>
</item>
我寫了這個功能,一切正常,除了「內容:編碼」字段,讓我這個錯誤:「通知:試圖讓非對象的特性」
function rssReader($url) {
$doc = new DOMDocument();
$doc->load($url);
$fields = array('title', 'description', 'link', 'pubDate', 'content:encoded');
$nodes = array();
foreach ($doc->getElementsByTagName('item') as $node) {
$item = array();
var_export($node, true);
foreach ($fields as $field)
$item[$field] = $node->getElementsByTagName($field)->item(0)->nodeValue;
$nodes[] = $item;
}
return $nodes;
}
告訴我們如何你試過...... – 2012-04-07 13:50:15
我認爲你必須瞭解更多關於命名空間 – Michelle 2012-04-07 14:00:44
您的命名空間是什麼意思?你能指導我嗎? – 2012-04-07 15:21:02