Jump to content

Archived

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

gerkintrigg

RSS Reader

Recommended Posts

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.

Share this post


Link to post
Share on other sites
i would recommend just getting an rss parser like [url=http://magpierss.sourceforge.net/]Magpie[/url] and using it to help you parse your feed. basically, with that, all you have to do is the following:
[code]
<?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";
}
?>
[/code]

hope that helps

Share this post


Link to post
Share on other sites
[quote author=extrovertive link=topic=112236.msg455563#msg455563 date=1161461269]
Does magpie works for RSS 2.0?
[/quote]

somewhat, but not entirely. RSS2.0 is [b]so[/b] much more flexible. from their todo list:
[quote]
Improve RSS 2.0 support, in all its wacky permutations (as much as I'm annoyed by it)
[/quote]

Share this post


Link to post
Share on other sites

×

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.