Hey,
I have used this php to fetch my blog's latest post:
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;
}
I learnt this off a tutorial as I wasn't sure how to do this task. However it works, but I keep getting this error printed in my error log:
[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
Any ideas?
Thanks!