Download understandingRSSFeed.zip - 0.9 KB
If you have tired to see the same contents each day on your Webpage and it attracts no more to your friends or colleagues. You want to bring more traffic towards your website but you don't have time to change or update the contents by your self daily. Also, you are craving to share your own contents over the worldwide web and to let people know when your page contents are updated.
Then trust me, RSS (Really Simple Syndication) Feed is exactly going to do the same thing for you. Today, with the blessing of RSS, we can truly make our WebPages attractive by automatically fetching and updating various contents from different sources. Simultaneously we can publish various contents for the worldwide and all its going to cost just one time development effort.
Few usages of RSS:
1. To display latest news, headlines, events n happenings
2. To display daily Weather updates
3. To display Joke of the Day, Quote of the day
4. To be notified about your favorite Blogs (web logs) when updated
5. To display daily Horoscope
Where to Find RSS Feed:
It is not very difficult to search the RSS feed containing your favorite contents by using your favorite search engine such as using Google you can filter your search by adding "FileType:rss" with your actual search string and this will restrict your search to '.rss' files only.
Although this is not the Rule, but most of the Websites providing RSS Feed use the <place w:st="on">Orange button (such as
) as a link to their RSS Feed.
As RSS is nothing but just another XML file with some reserve tags so using RSS to populate your webpage takes not much time.
Validating RSS Feed:
RSS feed can be validated by writing your own utility or by checking the whole XML file elements manually. However there are tools available to validate whether the specified RSS Feed is correct or not. You can validate your Feed by one click from the sites below;
As RSS Feed is just another XML file so all the rules and regulations to make XML File are applicable to it such as it must be well formed and each opening tag must need to be closed.
When Not to use RSS Feed:
Avoid using RSS feed if required contents are updated infrequently. As it always read and parse XML file so if the changes are very occasional then using RSS may result just the wastage of server time and resources.
Latest available version of RSS is 2.0 and it is backward compatible with its previous version i.e.; RSS 0.91. RSS 2.0 is much simpler and easier to use than its previous version.
Formation of RSS Feed:
RSS Feed is just like any other XML file except that it is created by following certain regulations such as each file must have <channel> element at the top most level. And each <channel> element must contain at least these three elements; <title>, <link>, <description>.
Also there are several optional elements that can come under the <channel> element; such as <image>, <pubDate>, <copyright>, <generator>, <category>, <cloud>, <webmaster>, <ttl>.
Title of the channel such as the name of the webpage providing this RSS Feed
Hyperlink to the Webpage that is providing this channel
Brief details of the channel i.e.; the purpose of the webpage providing this channel
To display the image
When this feed was published
To whom this RSS Feed copy righted to
Tells that by which program/software the Feed has been generated.
Tells the category of the feed.
This notifies the registered processes when any update occurs in our feed.
Webmaster email address can be defined here.
Stands for "Time to Live", defines the cached time of the feed.
<image> element also contains three required elements <url>,<title>,<link> while the other three elements <width>,<height>,<description> are optional.
Now where should we place our contents that are supposed to be changed frequently? For this we have another element named <item> under our <channel> element. Each <channel> usually contains one or more <item> elements. It can also be said that <item> element is the heart of a RSS Feed. An <item> contain three compulsory elements; <title>, <link>, <description>.
Title to be displayed such as a news headline, today's joke title
Hyperlink to the page containing whole story
Brief details of the item.
Contains email address of the author of the item
This is used to organize the items by categories
Contains link of the comments about particular item
Used to include any media file with the item
A unique identifier used to identify particular item
Tells when the item was published
Contains the source of the item such as the item's information is coming from some where else
Well to Syndicate the contents, we just need to have a valid RSS file and to create a link on our Webpage. Although, it is not a rule, but people use the orange buttons such as or for this purpose. So either you can follow this de facto standard or you can link your RSS Feed with any of your favorite image or text such as below;
<a href="MyRSSFeed.rss"> <img src="images/myImage.gif" width="20" height="20"> </a>
<a type="application/rss+xml" href="MyFeed.rss"> My RSS Feed Link </a>
Sample RSS Feed:
<title> Nawaz Ijaz's Blog </title>
<link> http://blog.360.yahoo.com/blog-RFHidsM_erFb5Sks9KqfGlOOxPA-?cq=1 </link>
M a nightmare trying to live a dream! Unpredictable... Don't forget & forgive so easily...!!
<language> en-us </language>
<lastBuildDate> Fri, 09 Mar 2007 13:20:27 GMT </lastBuildDate>
<title> Bad patch continued for Tigerz... [Series Review: by Farhan Asad] </title>
<link> http://blog.360.yahoo.com/blog-RFHidsM_erFb5Sks9KqfGlOOxPA-?cq=1&p=9 </link>
The Epic continued as two arch rivals continued in a heated contest. Tigers came to
the foreground with their oath of beating the Stallions mercilessly. But the Stallions
went into battle with resounding confidence, substantiated with their continuous
winning streak. <br /> <br /> The first match was a nail bitter. Stallions scored 75 runs
in their quota of 8 overs, after struggling earlier on in the innings...
<pubDate>Tue, 06 Feb 2007 09:02:17 GMT</pubDate>
<title> For All Kangro Lovers! </title>
<link> http://blog.360.yahoo.com/blog-RFHidsM_erFb5Sks9KqfGlOOxPA-?cq=1&p=8 </link>
Well friends if you like kangros then this is for you only :)<br/>
<pubDate> Thu, 01 Feb 2007 07:44:08 GMT </pubDate>
<title> Me @ MSN Spaces....!! </title>
<link> http://blog.360.yahoo.com/blog-RFHidsM_erFb5Sks9KqfGlOOxPA-?cq=1&p=1 </link>
Well... m already on MSN Spaces n feeling comfortable with dat... have aleady
put lot ov stuff in ma MSN webpage... can u give me the reason to continue yahoo 360 simultanously??
u can always meet me on my MSN Space... your feedback n comments are more than welcome... :)<br/>
<br /><a href="nawaz.spaces.live.com">nawaz.spaces.live.com</a><br />
<pubDate>Fri, 17 Nov 2006 12:55:50 GMT</pubDate>
Above piece of RSS Feed is taken from my personal Blog... you may check the RSS File in detail at the URL below;
Parsing RSS Feed and fetching the required contents:
Now as we have seen that RSS Feed is just an XML file with well defined DTD so by making use of any parser in any programming language, we can extract the required information from this XML file.
Now, we are going to make a simple ASP 3.0 webpage where we will parse and extract the Title, Publication Date and the Link to read the details. Then we will display the extracted contents in two different ways.
First, we will set the RSSFeed path as an input such as below;
const inputRSSFile ="http://blog.360.yahoo.com/rss-RFHidsM_erFb5Sks9KqfGlOOxPA-?cq=1"
Then we will create a "serverxmlhttp" object to load the above RSSFeed.
Set xmlhttp = Server.CreateObject("msxml2.serverxmlhttp")
xmlhttp.Open "GET", inputRSSFile, false
set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument")
objXMLDoc.async = false
Now as the whole RSSFeed has been loaded into memory so we can extract our desired contents such as we are extracting the "Title, Publication Date and Link" over here;
for each ParentNode in objXMLDoc.documentElement.childNodes
for each ChildN in ParentNode.ChildNodes
if childN.nodeName= "item" then
for each tmpNode in childN.ChildNodes
if tmpNode.nodeName = "title" then
marqueeString= marqueeString & tmpNode.text & " "
response.write "<font size=""2"" face=""Verdana""><b>" & tmpNode.text & "</b></font><br>"
if tmpNode.nodeName = "pubDate" then
marqueeString= marqueeString & "[" & tmpNode.text & "]" &" "
response.write "<font size=""1"" face=""Verdana"">" & tmpNode.text & "</font><br><br>"
if tmpNode.nodeName = "link" then
marqueeString= marqueeString & "<a target=""_blank"" href=" & tmpNode.text & ">" & "[see details]" & "</a>" & " "
response.write "<font size=""1"" face=""Verdana"">" & "<a target=""_blank"" href=" & tmpNode.text & ">" & "[see details]" & "</a>" & "</font><br>"
The above piece of code is quite self explanatory. Simple Loops and If statements.. Do I need to explain it too? Okay, lets do this too :-) First, we find an "Item" tag and then we are looking for our desired "title, pubDate, link" tags here.
"response.write" directly displays the desired contents on out ASP webpage. While "marqueeString", keeps on concatenating the same contents. In the end, we are setting this "marqueestring" to dhtml marquee object such as below;
<marquee scrolldelay="120" style="font-family: Verdana; font-size: 9pt">
<%= marqueeString %>
Below is the screenshots of our example's output. In "RSS Feed - Sample usage 01", we are displaying the contents inside <Div> tag and in "RSS Feed - Sample usage 02", a marquee (starting from right to left) has been used to display the same contents.
Thats All !!
Congratulation friends, we have learned what RSSFeed really is; and how we can make use of it... Cheers...