1

Error:

Warning: simplexml_load_file(): feed.rss:2393: parser error : xmlParseEntityRef: no name in C:\xampp\htdocs\mklbet\index.php on line 16

Warning: simplexml_load_file(): <title>We have a winner & it is ME</title> in C:\xampp\htdocs\mklbet\index.php on line 16

My problem is that when i use simplexml_load_file($url) - and the in the xml feed there is a '&' it will make an error - how can i get this to work?

if (file_exists($url)) {
       $tips = simplexml_load_file($url);

    } else {
        exit('Failed to open stream');
    }

        foreach ($tips->channel->item as $entry) {

            $title=htmlentities($entry->title);
}
}

This is how i wrote the code, i am getting the rss feed from another site so i cant edit the character

  • The XML-File you use is not correctly encoded - it has to be `&` instead of `&`. – MrTux Aug 19 '14 at 12:04
  • I am aware of that the feed looks like this: We have a winner & it is ME http://www.links.com/tip/946079&utm_medium=tips&utm_campaign=feed-rss So it is only the title that is wrong, but other places it uses & as it should - and i do not have access to edit the feed – Jens Peter Aug 19 '14 at 12:14
  • As a hack you could replace "& " by "& " before parsing, however, this won't work with "A&B" - Best way would be to inform the creator of the buggy RSS feed. – MrTux Aug 19 '14 at 12:15
  • Did you see : http://stackoverflow.com/questions/1674035/how-to-shut-up-simplexml-on-malformed-data – hendr1x Aug 19 '14 at 19:25

0 Answers0