Page 1 of 1

PHP RSS application

Posted: Sun Dec 14, 2008 3:21 pm
by morris520
Hi

I am writing an application to dispaly selected rss feeds. However, I found out some strange points that I don't understand. So can anyone please give me a hand?

The problem is like the follows:
There are two feeds I want to add but when I add the "bbc" feed the contents is not matching. I found there is an additional title called "bbc news" without any contents, so the title and description of the rss actually is misplaced.

I am not very familiar with RSS so can I get rid of that additional lines? The first feed doesn't have this problem.

Many thanks

http://rss.reddit.com/

http://newsrss.bbc.co.uk/rss/newsonline ... rss.xml

Re: PHP RSS application

Posted: Sun Dec 14, 2008 8:44 pm
by infolock
Are you sure it's not the logo image that's at the far right that you're seeing?

Hmm, let me try grabbing this rss myself and i'll let ya know what i find..


Edit: Also, have you tried using Magpie RSS or Simple XML?

Re: PHP RSS application

Posted: Sun Dec 14, 2008 8:55 pm
by infolock
Here is what I used for the BBC and it works fine for me?

Code: Select all

 
<?php
echo <<<EOD
<html>
<head>
  <title></title>
</head>
<body>
EOD;
 
$url = 'http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/uk/rss.xml';
$xml = simplexml_load_file($url);
$rss = $xml->channel;
 
echo <<<EOD
  Link = $rss->link <br />
  Title = $rss->description <br />
  Publish Date = $rss->pubDate <br /><br />
  Item Information = {<br /><hr />
EOD;
  foreach ($rss->item as $item) {
    echo <<<EOD
    
    Item Link = $item->link <br />
    Item Title = $item->title <br />
    Item Description = $item->description <br />
    <hr />
EOD;
  }
  echo "}";
echo "</body></html>";
?>