Friday, 9 August 2013

Remote XML file is poorly written causing parsing errors

Remote XML file is poorly written causing parsing errors

pI am writing an RSS type reader webpage to parse information from some
game websites./p pOne of the games RSS feed is poorly written./p pThey did
not bother wrapping the description into CDATA and it is giving errors
using simplexml_load_file to parse. /p pHere is the function I wrote to
parse it:/p precode function displayAll($url) { $url =
https://www.game.com/newsfeed/rss.vm; $game = simplexml_load_file($url);
$item = $game-gt;rss-gt;channel-gt;item; foreach ($item as $items) { echo
'lt;ligt;'; echo ''.$items-gt;title.''; echo ''.$items-gt;description.'';
echo ''.$items-gt;link.''; echo 'lt;/ligt;'; } } /code/pre pI am getting
the following errors:/p precode Warning: simplexml_load_file()
[function.simplexml-load-file]: https://www.game.com/newsfeed/rss.xml:15:
parser error : Entity 'nbsp' not defined in /results.php on line 27
Warning: simplexml_load_file() [function.simplexml-load-file]:
https://www.game.com/newsfeed/rss.xml:20: parser error : Entity 'nbsp' not
defined in /results.php on line 27 /code/pre pGetting multiple of the same
error all revolving around the html poorly written in the feed./p pI am
asking for how to resolve this, is there a way to convert the html back to
letters/spaces/etc tags in the description of the xml before it is parsed?
/p pAny suggestions would be appreciated./p

No comments:

Post a Comment