Anatomy of RSS

Before you create an RSS file you need to know a little bit about the format and structure of RSS. First lets look at what a very basic Podcast file might look like:

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
    <channel>
        <title>Gem_Sqash</title>
        <link>http://adam.engagetv.com/</link>
        <item>
            <title>This is my show</title>
            <enclosure url="http://adam.engagetv.com/gem_sqash/01_vlf.mp3" length="1000" type="audio/mpeg"/>
            <pubDate>Mon, 1 Apr 2007 12:00:00 GMT</pubDate>
        </item>
    </channel>
</rss>

We need to break down this information into palatable chunks, first lets look at what an element is :

RSS Elements

In the above example you can see many words that appears between < and > brackets. This is called an element. For example <title> is an element, also called the title element. When we say 'put some text in the title element' we mean something like this :

<title>Gem Squash</title>

Tags 

Every element has what is known as a start tag and an end tag. The start tag contains just the name of the element. The end tag is the same except that it has a '/' preceding the element name. A start tag looks like this '<title>'and an end tag looks like this '</title> '. 

An element must have an open tag and a corresponding closing tag (there is one exception to this rule but we will come to it later).

You can put other elements between open and closed tags like so:

<item>
            <title>This is my show</title>      
</item>

The rules governing the use of tags is XML. XML is very strict and if you make one small error then the file is said to be 'invalid' and it will not work. So watch those open and close tags carefully.

The important thing to remember at this stage is that you don't need to understand to much about the mechanics of XML tags. If you need to use it, its best to find an example online that is close to what you want, copy it, and change the information to reflect your own Podcasts. You will learn the syntax as you need to.  For now you just need to make sure the document is following exactly the format described here.

Attributes 

What do elements do?

XML tags are used to store information. I could use tags in a XML document to store information about a dog (don't try this in your Podcast example it won't work! its just an example to show you how tags work). Writing something like:

<name>Ralph</name>
  

is like saying "the name is ralph". However, in this example we don't know what is called Ralph. Is "Ralph" a person? a dog? a cat? my neighbor? So I have to say who the name belongs to:

<dog>
     <name>Ralph</name>
 </dog>
  

If the dog Ralph was black I might write:

<dog>
    <name>Ralph</name>
    <color>black</color>
 </dog>
  

Using this simple structure we can describe an object like a dog with as many characteristics as we like. In the world of XML the dog is known as an element and the characteristics it has are known as its child elements.

Now lets take our little fantasy XML world further. Lets say there is a man named 'Pete' in this world. We would write this like so:

<man>
    <name>Pete</name>
</man>
  

So, if we were describing Pete and Ralph together we could do it in the same XML file like so:

<man>
    <name>Pete</name>
</man>
<dog>
    <name>Ralph</name>
    <color>black</color>
 </dog>
  

Ok...so here a nice trick. Lets say that actually the dog Ralph belongs to Pete. In our XML document we can display this like so:

 <man>
     <name>Pete</name>
        <dog>
            <name>Ralph</name>
            <color>black</color>
        </dog>
 </man>
  

As well as properties (eg. name or color) belonging to an object, objects (for example - the dog) themselves can belong to other objects.

Similarly, we can use XML tags to store information about a Podcast. A tag for a single Podcast audio file is an object known as an item (its not a very descriptive name but the gods of RSS have determined we must use it). The following example shows how we store information about the name and published date of a Podcast item (there are many more properties that could also be used) :

<item>
            <title>This is my show</title>
            <pubDate>Mon, 1 Apr 2007 12:00:00 GMT</pubDate>
</item>
  

The Podcast XML

Ok, so lets get back to the world of XML for Podcasts. The basic structure is this:

<channel>
    <item></item>
</channel>

channel 

A channel is derived from the language of television. In television you have channels. Each channel is a certain grouping of programs, and you know you can tune into that channel to watch a particular kind of show. RSS allows this kind of grouping. You could have several channels in one RSS document and users could decide which is the one they wish to subscribe to. In this way if you produce a lot of audio content of different genres (for example) you can decide how to group these.

In our example we have just one channel. 

Each channel needs a name. So here you can give your channel a name using title tags. For example, this is all that is needed to give a channel a name :

 <channel>
        <title>Gem_Sqash</title>
 </channel>
  

item 

Next we give the channel its first program (audio file), this is done using an item tag and giving the item tag some properties.:

    <channel>
        <title>Gem_Sqash</title>
        <item>
                <title>This is my show</title>
                <enclosure url="http://adam.engagetv.com/gem_sqash/01_vlf.mp3" length="1000" type="audio/mpeg"/>
        </item>
    </channel>
  

You will notice there is one line here that doesn't  doesn't fit the rules we have learnt so far. The enclosure tag.

enclosure

  <enclosure url="http://adam.engagetv.com/gem_sqash/01_vlf.mp3" length="1000" type="audio/mpeg"/>
  

The above line is the enclosure element, and it just describes the location online of the audio file, its length, and what kind of audio file it is. You will notice it doesn't have a corresponding closing tag. Don't worry about, its ok, the rules for Podcasts tags allow this. The url is the location of the audio file online and it has to have a full url, this means it must be of the format "http://www.mydomain.com/myaudiofile.mp3" - the location url must start with "http://". The additional information included in the enclosure element are length and type. The length refers to the filesizeof the program not the duration. If you do not know what the file size is (measured in bytes) then exclude the information like so:

  <enclosure url="http://adam.engagetv.com/gem_sqash/01_vlf.mp3" type="audio/mpeg"/>
  

The type refers to what kind of audio file it is. I recommend for your first example you use and MP3 file, in which case you would leave this as it is.

pubDate

The pubDate element lists the date that the item was published. Some podcast programs will not recognise a new program (item) unless this information is present. 

xml and rss 

Lastly we need to include two lines at the top of the document. Take notice of the first two lines in our original example:

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  

These are necessary to include in your file, if you don't include them your podcast won't work. These two lines determine what type of tag structure we are using for the feed. This is necessary as the softwares that need to interpret this information need to know what rules to follow. Make sure you type these lines exactly as you see them above. In the above example we are stating that we want to use the XML version 1 syntax together with the RSS version 2 rules for tags. There are many other varieties,which is why its important to state here which variety of RSS file is being used.

The complete file

So our final XML file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
    <channel>
        <title>Gem_Sqash</title>
          <link>http://adam.engagetv.com/</link>
          <item>
              <title>This is my show</title>
              <enclosure url="http://adam.engagetv.com/gem_sqash/01_vlf.mp3" length="1000" type="audio/mpeg"/>
              <pubDate>Mon, 1 Apr 2007 12:00:00 GMT</pubDate>
          </item>
     </channel>
</rss>

Ok. If you replicate this and use you own information then you can put the file (and audio file) online and you have your first Podcast!