im using a very common php script to parse RSS;
function getRSS($source,$quien) {
$start = microtime(true);
ini_set('default_socket_timeout', 1);
global $arrFeeds, $downItems, $time_taken;
$arrFeeds = array();
$ch = curl_init($source);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($ch);
curl_close($ch);
$doc = new DOMDocument();
$doc->loadXML($content);
foreach ($doc->getElementsByTagName('item') as $node) {
$itemRSS = array (
'title' => sistema($node->getElementsByTagName('title')->item(0)->nodeValue),
'desc' => sistema($node->getElementsByTagName('description')->item(0)->nodeValue),
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue
);
echo(sistema($node->getElementsByTagName('title')->item(0)->nodeValue)."<br>");
array_push($arrFeeds, $itemRSS);
$downItems+=1;
}
$time_taken = microtime(true) - $start;
if ($downItems>1) {$nu=mysql_query("UPDATE feeds SET lastcheck = NOW() WHERE id = '".$quien."';");}
}
When i test this code with the rss news feed from google it works just fine, but if i try it with this other rss feed, it wont work, and gave A LOT* of errors like; Warning: DOMDocument::loadXML() [domdocument.loadxml]: Opening and ending tag mismatch: P line 5 and BODY in Entity, line: 6 in C:\Users\Domingo\Dropbox\www\temp\parser.php on line 18. The two above rss files ARE valid, the only different i found between are that one of those have the line: <?xml version="1.0" encoding="utf-8"?>
and the other no. Is this the problem? And how can i solve this? Thanks for any help, and PLEASE do not suggest to use an rss parser libary.
(*) more errors like: Warning: DOMDocument::loadXML() [domdocument.loadxml]: Opening and ending tag mismatch: BODY line 3 and HTML in Entity, line: 6 in C:\Users\Domingo\Dropbox\www\temp\parser.php on line 18
and Warning: DOMDocument::loadXML() [domdocument.loadxml]: Premature end of data in tag HTML line 1 in Entity, line: 7 in C:\Users\Domingo\Dropbox\www\temp\parser.php on line 18