ravi181229 Posted September 12, 2008 Share Posted September 12, 2008 Hi, When I import B2livetve RSS Feed, it displays following error: SimpleXMLElement::__construct() [function.SimpleXMLElement---construct]: Entity: line 1: parser error : xmlParseEntityRef: no name I have debugged and tested in RSS Feed Validator and found that xml is using a <guid isPermalink="false">19644</guid> where this is a typo (XML is case-sensitive; for example, isPermalink and isPermaLink have no relation to each other, and only the latter has any meaning in the RSS 2.0 standard). Then I replaced 'isPermalink' with 'isPermaLink' in getFeed script, it just reduced few errors. It still displays error. my code: <?php $link = 'http://www.b2livetv.com/xml/nowh.asp'; $rss_feed = file_get_contents($link); $rss_feed = str_replace("isPermalink", "isPermaLink", $rss_feed); $B2livetv = new SimpleXMLElement($rss_feed); $casts = $B2livetv->channel->item; foreach ($casts as $cast) { echo "Title :".$cast->title; } ?> Please help me out. Thanks, Ravi Link to comment https://forums.phpfreaks.com/topic/123931-solved-rss-feed-displays-xml-error/ Share on other sites More sharing options...
rhodesa Posted September 12, 2008 Share Posted September 12, 2008 The problem I see in the feed is this line: <title>NCAA Washington & Lee vs Roanoke</title> where the & should be & If you can control the source of the feed, make the correction there. If not, try this: <?php $link = 'http://www.b2livetv.com/xml/nowh.asp'; $rss_feed = file_get_contents($link); $rss_feed = str_replace('&','&',$rss_feed); $B2livetv = new SimpleXMLElement($rss_feed); $casts = $B2livetv->channel->item; foreach ($casts as $cast) { echo "Title :".$cast->title; } ?> Link to comment https://forums.phpfreaks.com/topic/123931-solved-rss-feed-displays-xml-error/#findComment-639752 Share on other sites More sharing options...
ravi181229 Posted September 12, 2008 Author Share Posted September 12, 2008 Hi rhodesa, Awesome. It worked. I have removed $rss_feed = str_replace("isPermalink", "isPermaLink", $rss_feed); from my code. It means "isPermalink" is fine. you know, When I validated xml in RSS Feed Validator, I got that for RSS 2.0 standard it should be "isPermaLink" with capital 'L'. Now, would you tell me how did you find the '&' issue(I am just eager to learn). Thanks a lot. Ravi Link to comment https://forums.phpfreaks.com/topic/123931-solved-rss-feed-displays-xml-error/#findComment-639774 Share on other sites More sharing options...
rhodesa Posted September 12, 2008 Share Posted September 12, 2008 I just went to the URL in Firefox. It pointed at the & for content inside XML tags, you need to convert special characters (or flag the contents as CDATA). the characters can be converted with this PHP function: http://us3.php.net/htmlspecialchars Link to comment https://forums.phpfreaks.com/topic/123931-solved-rss-feed-displays-xml-error/#findComment-639776 Share on other sites More sharing options...
ravi181229 Posted September 12, 2008 Author Share Posted September 12, 2008 rhodesa, Thanks a lot for explanation. Ravi Link to comment https://forums.phpfreaks.com/topic/123931-solved-rss-feed-displays-xml-error/#findComment-639794 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.