Forum

DOMDocument Error - Feed No Longer Reads

2010-09-04 18:08:06

moxbydesign

Hi there, For quite a while the RSS reader was working absolutely fine. I use the reader on a client file to ensure that 'Your Money' from the BBC site is loaded. but now it's not working at all. The full error is below. I made sure I was using the latest version of rsslib.php and also made sure there were no other PHP script errors in the files calling or being called - and nothing. I've also used the pre-created rss-links.php and it returns the same error. The server is parsing the script as PHP5 so that's not the error-creator. Can you help, please? The client is an accountant/VAT consultant and this error does not look professional. Many thanks. Kind regards, Martin P.S. having issues posting... may have to put the error in a reply.
2010-09-04 18:12:46

moxbydesign

Okay, I can't post the actual error in this forum... but here' the site error:- www.nenebusinessservices.com/php-bin/rss-error.txt Hope this helps.
2010-09-06 02:43:02

scriptol

Hello, The PHP Document->load function is not able to parse the feed because it is not XML well-formed. Typically this error comes from a HTML unterminted code such as for exemple &nbsp that must be   It is possible this line is the source of the error:
Q&A: Retirement rules and you
The & code should be converted to & Maybe this is related to the DOCTYPE of the XML document?
2010-09-06 03:36:30

moxbydesign

Hi there, Okay, given this is the BBC's news feed we are talking about here (www.bbc.co.uk) - I cannot change the XML document itself... can I add a line of code within your script to alter the & to and & while the XML file is being read? Or can you patch this up quickly? I have just reloaded the feed and can't see that line, but it may be way down the list - what do you suggest?
2010-09-06 03:54:10

scriptol

Actually you have to load the file before to parse is with the PHP function. This can be donne with file_get_contents($url) or Curl.
$content = file_get_contents($url);
$content=@str_replace("&","&",$content];
$doc  = new DOMDocument();
doc->loadXML($content);
or with Curl
    
$doc  = new DOMDocument();
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
url_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
curl_close($ch);
$result=@str_replace("&","&",$result];
doc->loadXML($result);
2010-09-06 10:27:28

moxbydesign

And where does this go in your code? Thanks for your help thus far, by the way :)
2010-09-06 10:34:41

moxbydesign

Never mind, I've patched the code and all is working fine now per: www.nenebusinessservices.com Maybe you can add these lines of code into the next release of rsslib as this 'error' is not your fault at all, but is down to publishers of RSS feeds, but this could be causing issues for webmasters across the board and this is a quick fix :) Many thanks! (p.s. I patched it using the first option you gave and it works a treat. Thanks!)