Jump to content

[SOLVED] RSS Feed displays xml error


ravi181229

Recommended Posts

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

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;
}
?>

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.