Search code examples
phpzend-frameworkfeeddomdocumentzend-feed

DOMDocument cannot parse XML


I'm using Zend_Feed_Atom to get a feed from a website but I'm receiving this error:

Message:

DOMDocument cannot parse XML: DOMDocument::loadXML() [domdocument.loadxml]: xmlParseEntityRef: no name in Entity, line: 827

I tried with another site and I had no error. I want to know why do I get an error with that particular page and what does this error mean. I have looked online and it says that is a problem with the encoding (Which I don't really understand).

my code is simple, its just

if($type_feed == "atom"){
    $nfeed = new Zend_Feed_Atom($address);  
}elseif($type_feed == "rss"){
    $nfeed= new Zend_Feed_RSS($address);
}

Any help would be awesome! thanks!


Solution

  • If the feed is busted then it is busted, there is little we can do about that.

    One method of getting around this is to use @ to suppress the error.

    if($type_feed == "atom"){
        $nfeed = @new Zend_Feed_Atom($address);  
    }elseif($type_feed == "rss"){
        $nfeed= @new Zend_Feed_RSS($address);
    }
    

    Note that this is not ideal as it will suppress everything when new is called.