【发布时间】:2010-06-19 12:01:39
【问题描述】:
我已经使用这个 php 来获取我博客的最新帖子:
function read_rss($display=0,$url='') {
$doc = new DOMDocument();
$doc->load($url);
$itemArr = array();
foreach ($doc->getElementsByTagName('item') as $node) {
if ($display == 0) {
break;
}
$itemRSS = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'description' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
);
array_push($itemArr, $itemRSS);
$display--;
}
return $itemArr;
}
我从教程中学到了这一点,因为我不确定如何完成这项任务。但是它有效,但我的错误日志中不断打印此错误:
[12-Jun-2010 06:13:36] PHP Warning: DOMDocument::load() [<a href='domdocument.load'>domdocument.load</a>]: Document is empty in http://www.prettyklicks.com/blog/?feed=rss2, line: 1 in public_html/includes/functions.php on line 153
[12-Jun-2010 06:13:36] PHP Warning: DOMDocument::load() [<a href='domdocument.load'>domdocument.load</a>]: Start tag expected, '<' not found in http://www.prettyklicks.com/blog/?feed=rss2, line: 1 in public_html/includes/functions.php on line 153
有什么想法吗?
谢谢!
【问题讨论】:
-
public_html/portfolio.php on line 16和public_html/includes/functions.php on line 79有什么内容? -
对不起,实际上与错误无关,我已编辑!原来的问题
标签: php feed domdocument