Jump to content


Photo

RSS Reader


  • Please log in to reply
3 replies to this topic

#1 gerkintrigg

gerkintrigg
  • Members
  • PipPipPip
  • Magician
  • 828 posts
  • LocationBristol, UK
  • Age:37

Posted 21 October 2006 - 12:54 PM

Hello.
I'd like a little help with an RSS feed problem. I have some code to scroll an RSS feed across the top of a site, and know that I want the <item> value from an XML RSS feed to be used in this scroll, but I'm at a loss to how to get this value into a PHP variable.

Please help.
Neil Trigger - http://www.ghostlypublishing.co.uk - Ghostly Publishing - Children's Fantasy Books

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 21 October 2006 - 01:04 PM

i would recommend just getting an rss parser like Magpie and using it to help you parse your feed. basically, with that, all you have to do is the following:
<?php
// require your magpie include
require_once 'rss_fetch.inc';

// define location of your RSS feed
$url = 'http://magpie.sf.net/samples/imc.1-0.rdf';
// parse the feed
$rss = fetch_rss($url);

$feedTitle = $rss->channel['title'];

// $rss->items holds all your items as an array
foreach ($rss->items as $item ) {
  $title = $item[title];
  $url   = $item[link];
  echo "<a href=\"$url\">$title</a><br />\n";
}
?>

hope that helps
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 21 October 2006 - 08:07 PM

Does magpie works for RSS 2.0?

#4 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 21 October 2006 - 08:16 PM

Does magpie works for RSS 2.0?


somewhat, but not entirely. RSS2.0 is so much more flexible. from their todo list:

Improve RSS 2.0 support, in all its wacky permutations (as much as I'm annoyed by it)


You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users