Catch 404 error on DOMDocument->load()

Mimzy

New Member
I am loading a bunch of rss feeds using DOM and sometimes one will 404 instead of producing the file. The problem is that the web-server sends out an html 404 page in place of the expected xml file so using this code:\[code\]$rssDom = new DOMDocument();$rssDom->load($url);$channel = $rssDom->getElementsByTagName('channel');$channel = $channel->item(0);$items = $channel->getElementsByTagName('item');\[/code\]I get this warning:\[code\]Warning: DOMDocument::load() [domdocument.load]: Entity 'nbsp' not defined\[/code\]Followed by this error:\[code\]Fatal error: Call to a member function getElementsByTagName() on a non-object\[/code\]Normally, this code works fine, but on the occasion that I get a 404 it fails to do anything. I tried a standard try-catch around the load statement but it doesn't seem to catch it.
 
Back
Top