Anatomy of an RSS File

How to Build an RSS File from Scratch

Format
mla apa chicago
Your Citation
Kyrnin, Jennifer. "Anatomy of an RSS File." ThoughtCo, May. 9, 2017, thoughtco.com/anatomy-of-rss-file-3469293. Kyrnin, Jennifer. (2017, May 9). Anatomy of an RSS File. Retrieved from https://www.thoughtco.com/anatomy-of-rss-file-3469293 Kyrnin, Jennifer. "Anatomy of an RSS File." ThoughtCo. https://www.thoughtco.com/anatomy-of-rss-file-3469293 (accessed October 20, 2017).
Rss enter key
pagadesign/E+/Getty Images

RSS or Really Simple Syndication is a very easy XML language to learn because there are only a few tags that are required. And what's really great about RSS is that once you've got a feed up and running, it can be used all over the place. Most Web browsers can read RSS, as well as readers like Google Reader and Bloglines. RSS is a powerful tool for any Web developers who want to increase the visibility of their Web sites.

Tools Required to Write RSS

  • A text editor: You can use almost any editor that will generate plain ASCII text. I prefer to use jEdit because it's free and it checks the XML for me as I write. But you can also use HTML editors like Dreamweaver or BBEdit.
  • An RSS validator: If you use an XML editor like jEdit, an RSS validator isn't absolutely required. But I find that errors creep in even in the best editors, so validating the feed is always a good idea.

A Simple RSS Document

This RSS 2.0 document has one item in the feed along with the feed information. This is the minimum you need to have a valid and usable RSS feed.


 
 A Sample RSS 2.0 Feedhttp://webdesign.about.com/rss2.0feed/
 An example of a simple RSS feed. This is the description of the feed itself, not an item.
 
 This is the most recent entry in my sample feedhttp://webdesign.about.com/rss2.0feed/entry.html
 This is the text that will appear in the feedreaders. It describes the post itself, not the entire feed.
 http://webdesign.about.com/rss2.0feed/entry.html
 
 
 
 

As you can see, a basic RSS document has very little required to create a fully functional feed. If you were to paste that code into an RSS validator, it would validate - which means that RSS feed readers could read it too.

The first three lines tell the user agent that this is an XML document, it's an RSS 2.0 file, and there is a channel:


 
 

The version information isn't required, but I find that it's a good idea to include that attribute on the tag.

Every feed should have a title, URL, and description. And that's what the

,

, and tags that live within the channel (but not within an ) define. For most feeds, these elements will never change once you've decided on your feed name and description.


 

A Sample RSS 2.0 Feed

http://webdesign.about.com/rss2.0feed/ An example of a simple RSS feed. This is the description of the feed itself, not an item.

The last part of the feed are the items themselves. These are the stories that will be syndicated by your feed. Each item is enclosed in an element.


 

Inside the item you find the same three tags we already know:

,

, and . They perform the same function as they do outside the item tag, but inside they reference just that one item. So the text inside the is what displays in the feed reader, the title is the title of the post, and the link is where the post links to.


 

This is the most recent entry in my sample feed

http://webdesign.about.com/rss2.0feed/entry.html This is the text that will appear in the feedreaders. It describes the post itself, not the entire feed.

The only new tag is the tag.

This element tells the user agent or feed reader what the unique URL is for that post. This can be the same URL as the link or a separate permanent link (permalink) for the item.

http://webdesign.about.com/rss2.0feed/entry.html

The only thing remaining is to close the item, the channel, and the rss. Because this is XML, all tags need to be closed.


 
 

Add New Items to the Top

Most RSS feeds consist of more than one item at a time. This way, if a customer is new to your site, they can see the last few posts, or all of them, if you keep them all in the RSS. To add a new post, just add a new item above the first post:

...
 A second posthttp://webdesign.about.com/rss2.0feed/entry2.html
 Now my feed has 2 posts
 http://webdesign.about.com/rss2.0feed/entry2.html
 
 
 ...

Additional Elements to Dress Up Your RSS Feed

The above RSS is all you need to create a feed, but there are a lot of optional tags that can help improve your feed and provide additional information to your readers.

The following are some of my favorite optional tags that you can use to improve your RSS Feeds.

  • - use this tag to tell the reader what language your feed is in. You can use standard language codes, or the language-country designation with country codes added on (like en-us for U.S. English).
  • - the copyright notice for your channel.
  • - the email address of the person responsible for the feed's content.
  • - an image of your feed's logo. This tag includes the sub-tags: ,,, , and .

Note, that the image

must match the channel

and the image dimensions cannot be larger than 144 pixels wide and 400 pixels tall.

All of the above tags go in the and describe the feed, rather than individual items, like this:

...
 A Sample RSS 2.0 Feedhttp://webdesign.about.com/rss2.0feed/
 An example of a simple RSS feed. This is the description of the feed itself, not an item.
 en-us
 Copyright 2007, Jennifer Kyrnin
 webdesign@aboutguide.com (Jennifer Kyrnin)
 About.com
 http://0.tqn.com/f/lg/s11.gifhttp://webdesign.about.com/rss2.0feed/
 144
 25
 
 ...

Now you can build your own RSS feed.