PHP RSS Reader

2008-11-12 5:33 am
我想用PHP寫一個RSS Reader, 但有一個Item叫<content:encoded>唔知點Read呀, 我係用PHP DomDocument();寫架!!

XML:
<item>
<title>Testing RSS</title>
<link>http://www.testing.com/</link>
<content:encoded>Content</content:encoded>
</item>

PHP Code:
$item = $dom0->getElementsByTagName("item")->item(0);
$title= $item->getElementsByTagName("title")->item(0)->childNodes->item(0)->nodeValue;
$content = $item->getElementsByTagName("content:encoded")->item(0)->childNodes->item(0)->nodeValue;

P.S.: 我Read到<title>同<link>架, 係Read唔到<content:encoded>咋...

謝謝!!

回答 (1)

2008-11-13 9:30 am
✔ 最佳答案
問題出在 XML
<content:encoded>Content</content:encoded> 是不合法的,將 tag 改為
<content_encoded>Content</content_encoded>

Colons (:) are reserved for Namespaces.


收錄日期: 2021-04-25 20:32:36
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20081111000051KK01833

檢視 Wayback Machine 備份