Reputation: 22966
Are there any free php/javascript libraries out there which would help in displaying an RSS feed as html?
Upvotes: 2
Views: 2334
Reputation: 11220
It's not actually a library either, but I would definitely recommand you to use XSL/XSLT.
Upvotes: 1
Reputation: 32918
In my Opinion Simplepie is one of the Best RSS parsers.
Here is an example:
require_once('simplepie.inc');
$feed = new SimplePie();
$feed->set_feed_url('http://simplepie.org/blog/feed/');
$feed->init();
$feed->handle_content_type();
<?php foreach ($feed->get_items(0, 5) as $item): ?>
<div class="item">
<h2 class="title"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
<?php echo $item->get_description(); ?>
<p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
</div>
<?php endforeach; ?>
Upvotes: 7
Reputation: 124878
Try Magpie RSS. It can parse RSS feeds to arrays which you can easily iterate through and build your HTML.
Upvotes: 2
Reputation: 401182
Maybe SimplePie might help, here -- quoting its FAQ, it's :
- A code library, written in PHP, intended to make it ridiculously easy for people to manage RSS and Atom feeds.
- An easy to use API that handles all of the dirty work when it comes to fetching, caching, parsing, normalizing data structures between RSS and Atom formats, handling character encoding translation, and sanitizing the resulting data.
Of couse, it will not do everything for you -- but it might help you get started.
Other solutions include, for instance, Zend_Feed_Reader
or MagpieRSS.
Upvotes: 4