Linto's Blog

Just another WordPress.com weblog

RSS Feed December 2, 2011

Filed under: RSS feed — linodavis @ 7:25 pm

Creation of rss feed in our site

 

1)      we need to create a xml file ,

2)      It has a general format (http://en.wikipedia.org/wiki/RSS

3)      It can create manually , or automatically using any software like  feedforall http://www.feedforall.com/

 

Display of  Rss feed in any site

 

1)      we need to use any parser for parsing the feed xml

2)      Example php parser for Rss feed is simplepie (http://simplepie.org/)

3)      After parsing the feed , just display in html as per our requirement

4)      Example code (ie simplepie) for rss parsing

 

<?php

require_once(‘simplepie.inc’);

$feed = new SimplePie();

$feed->set_feed_url(‘http://www.empoweringparents.com/RSS/rss-debbie-pincus.php’);

$feed->init();

$feed->handle_content_type();

?>

 

<?php foreach ($feed->get_items(0, 5) as $item): ?>

 

<div>

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

 

 

5)      In set_feed_url, we need to give the path of the Rss xml

 

6) http://stackoverflow.com/questions/2037351/output-rss-feed-as-html

 

How to display Rss feed in browsers

 

While we taking any site, then if there is a orange icon is displaying

(in IE  below the address bar of the  browser, In Mozilla it is under the bookmark option)

Then it means that site provides rss feed.

Then by clicking that orange button, we can subscribe it and  we can show it on our browser

 

 

For getting this option in our site, we need to  add the following code , under the header tag

 

<link rel=”alternate” type=”application/atom+xml” title=”Feed for question ‘Output RSS feed as html?’” href=”linto.xml”>

 

Where href is the location of the xml file, that will generate the rss feed

Advertisement
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.