Howto Create an RSS 2.0 Feed

September 13, 2005

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">

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>
<description>This is my rss 2 feed description</description>
<lastBuildDate>Mon, 12 Sep 2005 18:37:00 GMT</lastBuildDate>

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.

<title>Title of an item</title>
<pubDate>Mon, 12 Sep 2005 18:37:00 GMT</pubDate>
<description>[CDATA[ This is the description. ]]</description>
<!-- 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.


Step 6: Validate your feed

Validate your feed using

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.

Like this? Follow me ↯

You might also like:

366 people found this page useful, what do you think?


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.
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...)
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.
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.
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-
Thanks. I was looking for something like this recently
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.
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:
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.
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.
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: for details.
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 :(
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?
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.
Is there a program that will automatically update my RSS feed for viewers when there are new articles placed on the site? Thanks!
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 : 2. how can i use html in contents of "description" tag? i don't know how can i use CDATA
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??
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?
what do you save the rss file as?
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.
Why not use software rather than handcoding a feed? There are so many good tools out there I use FeedForAll and it saves a whole lot of time and effort.
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 anyone has a solution?
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
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!
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?
This stuff did not work AT ALL. My feed validator keeps giving me errors. Really aggrivating. Really aggrivating.
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 every minute? I want updated stuff to be shown immediately. Thanks!
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?
is rome compatible to tomcat to install rome? and jdom?. where to extract those jdom and rome folders.. Thanks.
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!
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
""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.
The quality of education is, is not lower than 15 years ago
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.
Hy, i am new in using and searching more informations about rss,i need to get adviced,regarding a few sites for help and to lern how to update the news. Thank you! wiew my e mail adress!!
I am using an xsl schema for my RSS feed, if a perticular feed is down. I need to know how to handle it gracefully so I dont show a nasty error message to the user. Is there a way to show a handled/custom error message if a feed is down??
I want to make a new line in only one description tag, but it display whole text in justify form. So tell me how i can create a new line without creating new description tag. such like a below. e.g. New News. \\Then new Line and print Another News.
so after creating this rss.xml, where should I put it so that the world can get it? this is an example of how to add images too to an rss feed.
I found this through google and noticed a lot of comments weren't answered. I posted a simple but full code example and some info--based on Pete's helpful overview here-- on my blog: dated 2/22/2009, I don't think the comments will let me paste the whole long link in here but I'll try:
I have a years worth of info that needs to be distributed weekly. There is a possibility that some of the info will change in the future but most is set. Is an RSS feed the tool to use or is there a better option?
Hi. Good article, but I use another grate program: RSS Channel Writer.
Cool Tip I'll try add it at my web
Might be worth it to mention - beyond the format, if you want to get the Time in the Standard format - you can use this format: #dateformat(DateConvert('local2utc',now()),'ddd, dd mmm yyyy HH:mm:ss')# GMT
This is a great tutorial - Thanks
Useful tutorial thanks, although as mentioned above, services like and take a lot of the hassle out of making and maintaining your own rss feed and also provide usage stats and other widgets to help your users keep up to date with your updates.
Hi Ray, I have been looking for recommendations on handling times in RSS feeds. Particularly, I am writing in the GMT time, but apparently somewhere, somehow, we need to offset this time to be correect for the person hitting the feed. I heard this can be done in CF, but I don't know if this needs to happen at the server... or how it's best done. Thanks for any links or suggestions. Jason
Hi Pete,

Thanks for this great information. I am using the following Php class to generate RSS feeds from my website (RSS2Writer):

In relation to your statement "Dates in RSS feeds should comply to RFC 822...", I have my feeds working usinf the XML date format (ISO 8601): YYYY-MM-DDThh:mmZ , YYYY-MM-DDThh:mm+04:00, etc.
Is ISO 8601 supported in RSS as well as RFC 822, or are my feeds working working because it ISO 8601 a common format used in XML and is accepted in RSS, but not recommended?


I had everything working but no images. Wasn't sure about CDATA. Now I got images! Thanks for the info. Nice!
You guys are the most innovative content distributors on the web, and I think you guys could check this site out and make a credit of it.
Emergency Soft has just released a new version of RSS Channel Writer. This comprehensive, yet easy-to-use software promises to be the most professional in its field.
hi guys. i'm sorry but i really don't understand how to add images to my feed posts. i only get text at the moment. could you help?
Hello axelk,
You can add images to your feeds by using the description tag of Item.
Here is an example..

<description><![CDATA[<img src= align=left alt='DVD Cover'/> An image from W3Schools ]]></description>

i am using rss v 2.0. i am trying to implement feed with input box. for that i have used <textinput> tag in channel tag. i have validated my rss. no errors came. but in my browser i am not able to see the input box with a button beside it. what is the problem in this.

Thank you on this post!
Thanks a lot
I have created an rss feed for my site for testing but don't know how to update it automatically.

When a new post is made or page is added why the feed is not updates. Please advice.

Thanks in advance
I have created an rss feed for my site for testing but don't know how to update it automatically.

When a new post is made or page is added why the feed is not updates. Please advice.

Thanks in advance
Great Blog. I add this Post to my bookmarks.
how i can add cdata in channal title.Please solve this problem .
how i can wrap the name of the channel in cdata
Thank You very much. That's the 1st time I never created my 1st news feed. Thank you

It is grateful for the help in this question how I can thank you?
You commit an error. I can defend the position. Write to me in PM.
Many thanks how I can thank you? - Nike Free Run+ 3 Dame

Foundeo Inc.