1

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!

kmatyaszek
  • 19,016
  • 9
  • 60
  • 65
raygo
  • 1,348
  • 5
  • 18
  • 40

2 Answers2

1

Take a look here: http://www.php.net/manual/en/class.domdocument.php#domdocument.props.recover

Proprietary. Enables recovery mode, i.e. trying to parse non-well formed documents. This attribute is not part of the DOM specification and is specific to libxml.

You can try:

$dom = new DOMDocument();
$dom->recover = true;

Also, take a look at my implementation: https://gitlab.com/DeepRSS/Reader/blob/a2723735ff3e3cdd7d85649c92d0115211ea9a0d/src/Core/Service/ZendReader/FeedParser.php#L99

Isinlor
  • 1,111
  • 1
  • 13
  • 22
0

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.

Jake N
  • 10,535
  • 11
  • 66
  • 112
  • But for example, Google Reader picks up the feeds that are malformed, how do they do it? And I tried with @new and still getting error – raygo Aug 09 '12 at 14:36
  • 2
    Sorry mate, I am Jake, not Google. I have no idea :-) – Jake N Aug 09 '12 at 15:32