Really Simple Syndication -- Really

By Curtis Dicken

Introduction to RSS (Really Simple Syndication)

Ever wanted to add RSS to your website but never really understood how RSS feeds worked or how to implement them? In this article we’ll give you a simple RSS generator that is made from HTML and JavaScript. We’ll show you how to use it to generate a feed, save that feed as an RSS XML file, and link your new feed to any website page.

The RSS Feed Generator

The code that you see below will let you manually generate the XML for a RSS feed. It generates only the most basic elements of a RSS feed, so keep in mind that there are other options that you could add to the generator. We will delve into the items that are generated in some detail in the next section. If you want to review the complete set of RSS 2.0 standards they are available on the website.


    <title>RSS Feed Generator</title>

<script language="javascript" type="text/javascript">

// <!CDATA[


function ButtonGenerateXml_onclick() {

  // variable used to build output

  var xmlOutput = '';

  // variable used to get object values

  var myDocumentObject = document.getElementById('RadioFullFeed');

  // add rss and channel only for full feed

  if (myDocumentObject.checked)


      xmlOutput = xmlOutput + '<rss version="2.0">\r\n';

      xmlOutput = xmlOutput + '<channel>\r\n';

      myDocumentObject = document.getElementById('TextChannelTitle');

      xmlOutput = xmlOutput + '<title>' + myDocumentObject.value + '</title>\r\n';

      myDocumentObject = document.getElementById('TextChannelLink');

      xmlOutput = xmlOutput + '<link>' + myDocumentObject.value + '</link>\r\n';

      myDocumentObject = document.getElementById('TextChannelDescription');

      xmlOutput = xmlOutput + '<description>' + myDocumentObject.value + '</description>\r\n';

      myDocumentObject = document.getElementById('TextChannelGenerator');

      xmlOutput = xmlOutput + '<copyright>' + myDocumentObject.value + '</copyright>\r\n';

      myDocumentObject = document.getElementById('TextChannelCopyright');

      xmlOutput = xmlOutput + '<generator>' + myDocumentObject.value + '</generator>\r\n';


  // build item

  xmlOutput = xmlOutput + '<item>\r\n';

  myDocumentObject = document.getElementById('TextItemTitle');

  xmlOutput = xmlOutput + '<title>' + myDocumentObject.value + '</title>\r\n';

  myDocumentObject = document.getElementById('TextItemPubDate');

  xmlOutput = xmlOutput + '<pubDate>' + myDocumentObject.value + '</pubDate>\r\n';

  myDocumentObject = document.getElementById('TextItemLink');

  xmlOutput = xmlOutput + '<link>' + myDocumentObject.value + '</link>\r\n';

  myDocumentObject = document.getElementById('TextAreaItemContent');

  xmlOutput = xmlOutput + '<description>' + myDocumentObject.value + '</description>\r\n';

  xmlOutput = xmlOutput + '</item>\r\n';

  // add channel and rss close tags for full feed

  myDocumentObject = document.getElementById('RadioFullFeed');

  if (myDocumentObject.checked)


      xmlOutput = xmlOutput + '</channel>\r\n';

      xmlOutput = xmlOutput + '</rss>';


  // show xml in text area

  document.getElementById('TextAreaGeneratedXml').value = xmlOutput;



// ]]>




    <form id="rssGenerator" action="">

        <span style="font-size: 16pt"><strong>Rss Feed Generator<br />


        <br />


        <input id="RadioItemOnly" type="radio" checked="CHECKED" name="GenerationMethod" />

        Item Only&nbsp;

        <input id="RadioFullFeed" type="radio" name="GenerationMethod" />

        Full Feed<br />

        <br />

        <strong>Channel Settings:</strong><br />

        <br />

        Channel Title:

        <input id="TextChannelTitle" type="text" /><br />

        Channel Link:

        <input id="TextChannelLink" type="text" /><br />

        Channel Description:

        <input id="TextChannelDescription" type="text" /><br />

        Channel Generator:

        <input id="TextChannelGenerator" type="text" /><br />

        Channel Copyright:

        <input id="TextChannelCopyright" type="text" /><br />

        <br />

        <strong>Item Content:</strong><br />

        <br />


        <input id="TextItemTitle" type="text" /><br />

        Publication Date:

        <input id="TextItemPubDate" type="text" /><br />

        Website Link:

        <input id="TextItemLink" type="text" /><br />

        Content:<br />

        <textarea id="TextAreaItemContent" cols="100" rows="4"></textarea><br />

        <br />

        <strong>Generated RSS XML:</strong><br />

        <br />

        <textarea id="TextAreaGeneratedXml" cols="100" rows="10"></textarea><br />

        <br />

        <input id="ButtonGenerateXml" type="button" value="Generate Feed" onclick="return ButtonGenerateXml_onclick()" />




How the Generator Works

In order to understand what the generator above does, you will first need to understand the basic structure of an RSS feed. The RSS feed is exactly as advertised, really simple. It consists of two basic sections, the channel and the item. Think of the channel as the newspaper and the item as each section of the newspaper. With any given feed you can have multiple channels (newspapers) each having multiple items (newspaper sections).

In order to define our channel we need to provide some basic information. The basic channel information that we have chosen to include is Title, Link, Description, Generator and Copyright. Of the five that we have selected, only the Title, Link and Description are actually required. There are also several other channel elements that we have chosen not to include which could easily be added to the code above. Here is an explanation for each of the channel elements that we have included:

Channel Title (title) [required]: This is the title of your feed, e.g. “My Cool Articles”.

Channel Link (link) [required]: This is the full url link to the website where your feed content resides, e.g. “”.

Channel Description (description) [required]: This is a short simple text description of what your feed contains, e.g. “Read technical articles on everything web. We specialize in tutorials on HTML, JavaScript and CSS.”.

Channel Generator (generator): This should be the name of the application or process you used to generate your feed. In our case we would say something like “ Manual RSS Feed Generator”.

Channel Copyright (copyright): This is where you copyright your feed. It’s always a good idea to copyright your work to retain proper ownership. The format should look something like “Copyright (C)2009 –”.

Within your newly created channel you can have as many items as you like, however, limiting yourself to somewhere between 10 and 20 items is a good rule of thumb. The generator provides you the option of outputting the entire RSS XML file content or just the item content. You will need to get the full feed content the first time that you create an RSS feed but after that you can generate “item only” and add each subsequent new item block to the top of your set of item blocks. An RSS XML file with multiple item blocks would look something like this:

<rss version="2.0">


    <title>My Cool Articles</title>


    <description>Cool feed</description>


    <generator>copyright (c) 2009</generator>


      <title>Article 2</title>




        Something about article 2.




      <title>Article 1</title>




        Something about article 1.




The elements of items that we have chosen to include are Title, Publication Date, Link and Description. Of those elements only Title or Description is required. Here is an explanation of the elements that we have chosen to include:

Title (title) [required if no description]: This is the title of your article or page where the content resides.

Description (description) [required if no title]: This is a short simple text description of your article or content. It shouldn’t be more than a few sentences and should not include any HTML.

Publication Date (pubDate): The date when the article or content was published. This will not necessarily be the same date as the date you generate the feed item.

Link (link): This is the full url link to the full article or page content, e.g. “”.

As for the generator code itself, it flows like this:

  1. User fills in appropriate information and clicks the Generate Feed button.
  2. The Generate Feed button executes the ButtonGenerateXml_onclick function.
  3. The script first examines the radio buttons and determines if it is generating a full or item only feed.
  4. If it is a full feed it adds the appropriate tags to the xmlOutput variable that we use to build the feed.
  5. It next builds the item.
  6. It next adds the proper closing tags if we are doing a full feed.
  7. Lastly, it assigns our newly generated RSS XML to the text area “TextAreaGeneratedXml” for easy copy and paste.
The process is fairly simple and straight-forward but keep in mind there is no validation with this script. So, if you put in bad or missing data you’ll end up with a bad or incomplete feed.

Creating Your RSS XML File

The hard part is now done. You have the content for your file, now all you need to do is create the actual XML file for the feed. Just open up Notepad or some other simple text editor, paste in your generated contents and save the feed with the .xml extension. Next upload the file to your web server and you are all done.

Linking Your Feed

Now that you have your feed in place you just need to link up any pages that you want to show the feed. To accomplish this, place this in your page <head> substituting the correct .xml file name and adding an appropriate title:
<link rel="alternate" type="application/rss+xml" title="My RSS Feed" href="MyRssFeed.xml" />


Generate your feed, link it to your page and then see that little RSS feed button light up on your browser. It’s really pretty cool. With only a little effort you can easily create a feed for your website content. You can also add a link to your feed from within any page content like this:
<a href=" MyRssFeed.xml">Link to my RSS feed!</a>
Happy feeding!

Make a Comment

Loading Comments...

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.
Thanks for your registration, follow us on our social networks to keep up-to-date