PHP RSS application

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
morris520
Forum Commoner
Posts: 60
Joined: Thu Sep 18, 2008 8:56 pm
Location: Manchester UK

PHP RSS application

Post 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
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Re: PHP RSS application

Post 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?
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Re: PHP RSS application

Post 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>";
?>
 
Post Reply