pf » Howto Create an RSS 2.0 Feed

Howto Create an RSS 2.0 Feed

web

If you can learn HTML, you can easily learn how to build your own RSS 2.0 feeds. I'll take you through the steps to creating an RSS feed from scratch.

Step 1: XML Declaration

Since RSS 2.0 must validate as XML, the first line in your rss feed must be the XML declaration.

<?xml version="1.0" encoding="utf-8"?>

The encoding is optional but recommended. If your using something other than UTF-8 be sure to change the above line.

Note: If you are using CFML and have whitespace due to the Application.cfm file you can reset the output buffer using <cfcontent reset="true">

Step 2: RSS Channel

In this step we need to open up the rss tag, and the channel tag, all of your feed content goes inside these tags.

<rss version="2.0">
<channel>

Step 3: RSS Feed Information

Next you place information about your RSS feed such as the title of it, the description, and a link to the the site.

<title>The title of my RSS 2.0 Feed</title>
<link>http://www.example.com/</link>
<description>This is my rss 2 feed description</description>
<lastBuildDate>Mon, 12 Sep 2005 18:37:00 GMT</lastBuildDate>
<language>en-us</language>

The lastBuildDate should be the date and time that the feed was last changed. Dates in RSS feeds should comply to RFC 822. In CFML the DateFormat mask would be ddd, dd mmm yyyy and the TimeFormat would be HH:mm:ss. Dates should be offset to GMT. The lastBuildDate tag is not required but is highly recommended.

Step 4: RSS Items

Next we enumerate over each RSS item, each item has a title, link, and description, publication date, and guid.

<item>
<title>Title of an item</title>
<link>http://example.com/item/123</link>
<guid>http://example.com/item/123</guid>
<pubDate>Mon, 12 Sep 2005 18:37:00 GMT</pubDate>
<description>[CDATA[ This is the description. ]]</description>
</item>
<!-- put more items here -->

Make sure you escape any characters that might cause your XML to invalidate, these characters include <, >, & - I like to enclose any content that may contain HTML inside a CDATA section.

Note: In CFML you can use the XmlFormat function to escape special characters in XML.

Step 5: Close Channel and RSS tags.

</channel>
</rss>

Step 6: Validate your feed

Validate your feed using FeedValidator.org.

Other things to take note of

  • Content Type - See my post on content types for RSS feeds
  • Encoding - You should include the encoding in your Content-Type HTTP header, and in the XML declaration.
  • Styling - If you want to make your RSS feed look a little nicer you can CSS stylesheet for your RSS feed.
  • Categories - It's a good idea to include category tags in your RSS feeds as well, these go inside the item tag. You can give an item multiple categories by adding a tag for each one.

I have just scratched the surface of what you can do with RSS feeds, so check out the RSS 2.0 Spec for more info.



Related Entries
108 people found this page useful, what do you think?

Trackback Address: 465/BA48A6DE5019AD7D7052FD50AE32FB4E
On 09/14/2005 at 12:14:04 AM MDT Mark H. wrote:
1
Thanks for this great information as always. Your CF Cookbook is an awesome resource as well.

I assume the answer to the following question is "yes" but figured I'd ask anyway before delving in, as you will likely know the answer off the top of your head.

You alluded to this in your posting... is it possible to evaluate cfml variables inside of the RSS <item> tags?

For instance: <item> <title><cfouptput>#feed1title#</cfoutput></title> <link><cfouptput>#feed1link#</cfoutput></link> <guid><cfouptput>#feed1guid#</cfoutput></guid> <pubDate><cfouptput>#feed1pubDate#</cfoutput></pubDate> <description><![CDATA[ This is the description. ]]></description> </item>

Thanks again for helping with the understanding of this powerful capability.

On 09/14/2005 at 3:02:28 AM MDT Tjarko wrote:
2
Also handy is to place the following tag in the headsection of your RSS <ttl>60</ttl> This wil make sure that an RSS reader does not read your feed more then 1 time every 60 minutes. (feeddemon etc...)

On 09/14/2005 at 9:24:23 AM MDT Pete Freitag wrote:
3
Hi Mark,

Thanks!

Yes you can generate an RSS feed with CFML variables just like you would a HTML page with CFML. So suppose you have a db table with company news. If you wanted to create a RSS feed for that you would do a <cfoutput query="news"> <item> ...</item></cfoutput> One thing to keep in mind is that all the content inside the tags needs to be XML save, so you either want to use CDATA or XmlFormat or both.

On 09/14/2005 at 9:27:05 AM MDT Pete Freitag wrote:
4
Tjarko,

Yes the TTL feature is very handy, I omitted it from this example because I didn't want to overload people with details. Also handy is the skipDays, skipHours tags, if your a business and you only update the content on weekdays you can tell readers to take the weekend off.

On 09/14/2005 at 7:19:00 PM MDT Mark Holton wrote:
5
Pete, Many thanks for the reply and great info. I am working on getting my first feed up and running in the next 5 weeks (among other work) and this is a great head-start/ encouraging questions. Thanks and cheers-

On 09/16/2005 at 4:23:50 AM MDT Sudar wrote:
6
Thanks. I was looking for something like this recently

On 09/16/2005 at 9:14:27 AM MDT Bill Smith wrote:
7
Or you could use a service such as Nooked, or FeedForAll

A whole lot easier...

On 09/16/2005 at 7:38:00 PM MDT Mark Holton wrote:
8
Thanks for these links, Bill. ...easier to use these services, well, maybe in the short term. It depends on what you want to do with RSS, what your goals are. Understanding the technology and how to create feeds makes it "easier" to leverage in your site(s), through automation, etc. Thanks again, Pete, for the great references. Looking forward to the next post.

On 09/17/2005 at 11:25:30 AM MDT cate wrote:
9
excellent 'how to.' just wanted to alert you to a free application that will create an xml file automatically. you just have to input your information. it's called, RSS WRITER and you can find it here: http://www.phelios.net/rss-writer.html

On 09/20/2005 at 10:36:23 AM MDT Surender Taalla wrote:
10
check out https://rome.dev.java.net/ to build dynamic RSS feeds using java.

On 10/04/2005 at 5:41:26 AM MDT George wrote:
11
Hi there, I have finished my RSS feed, tested it and all works perfectly, but when I remove an article from my feed it still showed in the reader. How do i get the reader to see the article is no longer part of the feed.

When using firefox Sage extension the reader notifies that the change has been made and removes the no longer available feeds. Whereas when using FeedReader, Feed Demon etc, this is not the case.

If someone could please help that would be great.

Thank you in advance

On 10/04/2005 at 5:41:55 AM MDT George wrote:
12
Hi there, I have finished my RSS feed, tested it and all works perfectly, but when I remove an article from my feed it still showed in the reader. How do i get the reader to see the article is no longer part of the feed.

When using firefox Sage extension the reader notifies that the change has been made and removes the no longer available feeds. Whereas when using FeedReader, Feed Demon etc, this is not the case.

If someone could please help that would be great.

Thank you in advance

On 10/04/2005 at 11:22:06 AM MDT Pete Freitag wrote:
13
George,

I think that depends on the reader - most of them will store a copy locally. So once you publish something to your RSS feed, you can remove it but some people will still get it - it's kind of like sending an email.

On 10/11/2005 at 11:40:41 AM MDT podcast.redevelopments.co.uk wrote:
14
Need help creating RSS 2.0 feeds for podcasting? Try this FREE online tool to help create your first RSS 2.0 XML file!

http://podcast.redevelopments.co.uk

On 10/17/2005 at 6:21:39 AM MDT Jamesy wrote:
15
Hello,

I'm very new to using RSS, I have one fundamental question:

How do I ensure that RSS readers update my feed when I update it?

I author a financial news RSS feed and it's important that new stories are updated promptly.

Can you help?

On 10/17/2005 at 8:51:01 AM MDT Pete Freitag wrote:
16
Jamesy, most rss readers will grab your feed every hour. You can use the ttl tag to specify a time to live for your feed, they will obey that if it is set higher than one hour, and some readers may grab it more often if it is set below an hour.

On 10/17/2005 at 8:54:34 AM MDT Jamesy wrote:
17
Thank you for the lucid response.

It is possible to specify a specific date to check for updates. I ask because my rss feed is updated once weekly at the same time each week.

- Thank you

On 10/17/2005 at 9:19:33 AM MDT Pete Freitag wrote:
18
Jamsey,

Yes, you can specify skip days, and skip hours in your rss feed as well, aggregators should not download your feed on a skip day or skip hour. See: http://blogs.law.harvard.edu/tech/skipHoursDays for details.

On 10/22/2005 at 9:02:35 AM MDT David Mimms wrote:
19
Nice comments about RSS. Thanks, I've now made my feed: http://www.itnewsnow.com/feed.rss

On 11/06/2005 at 1:11:40 PM MST Mike wrote:
20
Hi everybody. I have a question about Feeds. I'm developing a Feed Reader, and I have to update the feeds, but I don't know how to do it. I'm working with java Rome. I'm guessing I can do it considering pubDate and the current date. I compare both dates to check if there are changes in those feeds. If you have a better idea, please advice me, I'll be thankful.

On 11/16/2005 at 10:18:59 PM MST netboard wrote:
21
hi, I have some questions, I tried something about rss ut I couldnt have what I want. I want to have rss same as down simple, with link . Have can I create it same ? If somebody can help me I will be very happy.

Thanks. sorry for my english :(

http://www.etikhaber.com/index2.php?option=com_rss&feed=RSS2.0&no_html=1

On 12/20/2005 at 2:00:00 AM MST inigoes wrote:
22
Is there any comparable RSS 2.0 tag to the <itunes:block> tag? I've redone my feeds, but the old ones still show up in aggregators and would like to eliminate them. Is there a way to do that with Yahoo Podcasts?

On 12/24/2005 at 9:00:18 PM MST Anonymous wrote:
23
Hi everbody. Firefox rss read icon view -0.92 update rss 2.0 ? -0.92 code change ? -page add code ?

http://www.donanimmerkezi.com/rss.php

On 12/25/2005 at 6:44:47 AM MST Anonymous wrote:
24
Alright, i am extremly new to rss. I've made my feed and now i have a problem. I have absoloutly no idea what to do next.

How do i go about adding this feed to a webpage. Is it just like adding a bit of html.

But most importantly, if anyone has a pda and knows of the program "Avantgo" i really need some help on how i can allow users to use it to find my channel. Sorry for the frustratingly ignorant questions.

On 01/04/2006 at 4:31:47 AM MST ss wrote:
25
I have created a feed. I want to know how to publish my feed, for my users to know, without using the Feed Readers available on the net. Please help me.

On 01/14/2006 at 9:57:46 AM MST Gladys C. wrote:
26
Thanks for this useful tutorial, it has helped me build my own feed in no time.

On 02/02/2006 at 8:48:21 AM MST Stacy wrote:
27
Is there a program that will automatically update my RSS feed for viewers when there are new articles placed on the site? Thanks!

On 02/06/2006 at 4:25:46 AM MST john wrote:
28
hi,

im using rapidfeeds.com to publish my feed.. its easy and simple with ther web based system...

On 02/09/2006 at 6:42:22 PM MST Mehdi wrote:
29
hi, thanx for your useful help i have tow questions : 1. How can I generate rss without this error by validators? : <i>should not be served with the "text/html" media type</i><br> this is my rss : http://www.naghsh.net/rss2.0.asp 2. how can i use html in contents of "description" tag? i don't know how can i use CDATA

On 02/13/2006 at 11:12:52 PM MST penis wrote:
30
psps can use rss's im on one now

On 03/05/2006 at 12:40:02 AM MST Snmz wrote:
31
Thanks for this sharing. I will try to install this on my sites. http://www.turkdreams.com http://www.flashgameworld.net http://www.sonmoda.com

On 03/15/2006 at 7:41:49 AM MST sheryl wood wrote:
32
I am in the process of opening an Yahoo store built with Yahoo Store Editor and even though the web design tools include and "Add On" feature and talk you through putting an RSS feed onto your store site, it doesn't work. I can perform all the directions and cut the html for the news section I want to put on my site, but then the directions become unclear as to WHERE TO PASTE IT! A call to Yahoo tech service said, "Oh, you can't really put an RSS feed on your site with those directions and I don't know how to do it either". Can that possibly be true?? www.alleducationalsoftware.com

On 03/16/2006 at 4:31:09 PM MST http://www.voyagevietnam.net wrote:
33
Useful! I will create one for our motorcycle tour site. Many thanks.

On 04/01/2006 at 2:43:18 AM MST jackie wrote:
34
thanks

On 05/22/2006 at 4:50:33 PM MDT www.resimekle.com wrote:
35
Thank you in advance

On 08/14/2006 at 5:19:03 PM MDT Evan wrote:
36
How do I have a feed without a <link> tag?

On 10/26/2006 at 9:10:10 AM MDT Tim Cummings wrote:
37
I am somewhat new at this. If I create an xml document for the RSS feed with CF variables, it will need to be saved as a .cfm document. How do I define the resulting output to be .xml instead of .html after parsing by the CFServer?

On 10/29/2006 at 8:31:48 PM MST Ryan wrote:
38
Stacy, as far as software that will automatically update your feed, checkout PodAdmin: http://podadmin.sourceforge.net. You put it on your web server (requires PHP), and it will parse out MP3 files and update your RSS file accordingly.

On 12/11/2006 at 6:13:06 PM MST R Cecil wrote:
39
what do you save the rss file as?

On 12/15/2006 at 3:53:54 PM MST Jason wrote:
40
You can name your feed file anything. You can even generate your feed dynamically!

The only important thing is that the correct XML is returned when someone visits your feed URL. I often use perl scripts, Java Server Pages, and ASP Class Libraries to generate feeds.

To get users to your feed, you can use several methods. One is to just tell them the URL (http://mysite/rss.pl OR http://mysite/myfeed.xml). You can also provide a hyperlink to the url (the XML/RSS image works great for this). Lastly, you can tell browsers that there is a feed associated with your webpage by adding the feed's URL to the header section of your webpage (remove spaces as needed):

< head > < link rel="alternate" type="application/rss+xml" title="My Feed" href="http://mysite/myfeed.xml" /> </ head >

On 12/27/2006 at 6:53:03 AM MST Deborah wrote:
41
I'm sorry but your instructions were incomplete. all you have are code snippets, but if someone like me for example, has no idea where to put them, what they are supposed to do, or what to save the file as (xml or cfml) all I get is, nothing from this at all. I need the whole thing coded out from top to bottm, what you are saving each page as, and how exactly do I get the feed to post on my page anyway, I got a link, and so what? how do I make that link post something on my site? It validated very well, but did nothing. I ended up going in circles, I even made and xsl sheet to try and get it to do something, and I got nothing. So whatever. I just need more detailed instructions. You have these code snippets and they are just hanging in the air. Which is probably why so many people have written something to you. It's just too vague. Sorry for the criticism but...I just wasted a half hour of my life for nothing on this. when I "could" be making money.

On 01/20/2007 at 7:42:50 AM MST Nety wrote:
42
Thanks. Question: I'm wondering if we really need to use the www prefix, at the beginning of the URL. Example, are those lines the same? <link>http://chunga.info</link> and, <link>http://www.chunga.info</link>

On 01/27/2007 at 8:22:58 AM MST Emma Snow wrote:
43
Why not use software rather than handcoding a feed? There are so many good tools out there I use FeedForAll http://www.feedforall.com and it saves a whole lot of time and effort.

On 01/31/2007 at 9:15:51 AM MST Mark Hathaway wrote:
44
I have managed to integrate an RSS 2.0 ASP script (similar to one found at http://www.codebeach.com/tutorials/displaying-rss-feeds-using-asp.asp) which retrieves RSS news feeds with a Dynamic Drive horizontal scroller, you can view a working example of this at yourdebate.net. The question I would like to ask is: Is there any way of retrieving the whole news article and any associated images and not just the Title, Link and Description within the ASP script, so when the user clicks on the link they will be able to read the news item on a page on my site? I will of course ask the BBC for permission to do this. Thanking you in advance.

On 04/04/2007 at 11:35:53 PM MDT jonathan wrote:
45
ive been trying to get images in my items,to output into my phone. but have been failing everytime. i have even tried src='loadimg.php?file=example.jpg'but somehow it doesnt seem to work, have seen a good example on http://www.view2offer.com/newpropertiesxml.aspx anyone has a solution?

On 04/19/2007 at 2:41:47 AM MDT Kay wrote:
46
you have a little mistake in your item definition

CDATA section starts with "<![CDATA[" and ends with "]]>":

but thanks for the rest, it saved me a lot of time ;)

On 04/28/2007 at 7:02:31 AM MDT Donna wrote:
47
Currently I have been using an RSS publication application called Flaremaker.

I wanted to find an application that would allow me to easily create my own feeds and publish them on my own website. Within minutes I had entered in the content and it produced a snip bit of code to put into my site. It?s so easy.

It also allows me to track all the items in my feeds. Flaremaker is a Very Cool application.

Check it out www.flaremaker.com

On 05/02/2007 at 8:35:00 AM MDT william wrote:
48
Hey, I'm a 17 year old that has a PodCast on my school's website and I am looking for help on how to connect an RSS Feed to the PodCast on the website so that iTunes will pick up the tag whenever someone searches on iTunes.

Please Help, I'm Totally LOST!!!

Thanks!!

On 05/17/2007 at 2:25:03 PM MDT Todd wrote:
49
Thanks! As a coder that needed to create a dynamic feed, and so can't use any of the popular RSS-generators, this post helped me very much! It was the first page out of 15 that I looked at the explained how to do it clearly and succinctly. This should be ranked at the top of google when searching for how to code RSS feeds. Thanks again!

On 05/21/2007 at 2:21:28 PM MDT fakhre wrote:
50
hey guys! thanks for all this.. but i m really new in RSS WORLD :) will guys please help me out about this.. where should i start? where i have my site which update its news section on almost daily bases.. thank you!

On 05/21/2007 at 2:24:00 PM MDT fakhre wrote:
51
also i would like to tell you that my site is written in asp (not .net). Is it possible to write asp generated data for RSS?

On 05/30/2007 at 10:32:43 AM MDT Shiv wrote:
52
Hey,

Thanx needed sumthin simple like this

On 06/02/2007 at 6:28:15 AM MDT fakhre wrote:
53
well its all fine, but i really want to know how can we write an XML file may be RSS.XML using any programing languag, my prior langs are ASP, .ASP etc. thanks!

On 06/20/2007 at 10:13:20 AM MDT tenfourzero wrote:
54
There's a website at www.IrisFeed.com that allows you to create an RSS/Atom feed for any website. Pop the URL in and the rest is done automatically!

Its very easy and doesn't require registration. Could save some headaches!

On 06/20/2007 at 4:55:08 PM MDT Mark E wrote:
55
This stuff did not work AT ALL. My feed validator keeps giving me errors. Really aggrivating. Really aggrivating.

On 07/25/2007 at 1:58:19 AM MDT lahuua wrote:
56
Feedity (www.feedity.com) seems to be a much simpler and quicker tool at building instant custom RSS feeds fro ANY webpage.

On 07/27/2007 at 1:48:05 PM MDT Philip wrote:
57
I'm definitely a newbie. Please help, if this is possible. Unfortunately, there are several parts to my question:

If a file is updated (or uploaded) in a folder on the server. Is it possible to have an RSS feed show that updated or new file and have a hyperlink to it?

Is it possible to have the RSS Reader integrated into my webpage so no client specific software is loaded? (What's a good reader for this?)

Is it possible to have the rss feed checked often...like every minute? I want updated stuff to be shown immediately.

Thanks!

On 07/30/2007 at 3:32:01 AM MDT comp wrote:
58
Hi,

I'm a newbie to RSS. I am creating a tool to read rss. Is there anyway i can know when a particular rss will get updated or do i have to reload the whole rss again after some time?

On 08/29/2007 at 10:01:27 AM MDT mr_allen wrote:
59
is rome compatible to tomcat 6..how to install rome? and jdom?. where to extract those jdom and rome folders..

Thanks.

On 09/04/2007 at 9:58:56 PM MDT Erin wrote:
60
i am trying to build a RSS feed for my year 11 IPT assignment and i am not sure if i am doing the right thing. I dont what to put in the link part since my website has not been published. Am i able to put it on my website even though it is not published. Thanks

On 09/12/2007 at 6:13:30 AM MDT Samuel Becket wrote:
61
Awesome very easy to understand.

On 09/16/2007 at 8:27:07 AM MDT Evan S wrote:
62
Thanks for the awesome crash-course in RSS Feeds. I do have one question: Is there any simple way to have my rss.xml file be automatically updated, or do I have to manually enter each item? Thanks again!

On 09/20/2007 at 8:21:44 PM MDT Nicole wrote:
63
Hi, I did my website by dreamweaver and I don't know anything about programming. So I don't know how to start to make a rss 2.0 feed. Can I create it in dreamweaver or wordpad or another software? Could you please tell me in plain details step by step. Thank you so much

On 10/08/2007 at 11:27:02 AM MDT plc programming wrote:
64
""When using firefox Sage extension the reader notifies that the change has been made and removes the no longer available feeds.""

thank you for this.

www.plcprogramming.org

On 10/20/2007 at 5:01:18 AM MDT motor wrote:
65
The quality of education is, is not lower than 15 years ago

On 10/20/2007 at 6:51:43 AM MDT abdulwahab wrote:
66
Hi. am new to blog and am finding it so difficult to post and i can't viewing my site in order to know where i can still proceed. also don't no mush about rss feed. pls help, thanks. from Nigeria.




  



Spell Checker by Foundeo





Subscribe to my RSS Feed: solosub RSS
Tags