Javascript – Output RSS feed as html

feedjavascriptPHPrss

Are there any free php/javascript libraries out there which would help in displaying an RSS feed as html?

Best Answer

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; ?>