"Foolproof systems don't take into account the ingenuity of fools." - Gene Brown

Writing An RSS Feed

Friday 9th September 2005

Categories: Guides, Internet, Code

Writing Each Item

Next, we need to create each individual item in the feed. This is relatively simple. Each item is started by <item> and ended with </item>. Inside each item, we have a title, a link and a description. This is similarly self explanatory. In this case, the link should point to the relevant article. For example, an item might look something like this:

<item>
<title>New Bean Eating Record</title>
<link>http://www.example.com/beans/newrecord.html</link>
<description>A man has broken the bean eating record by eating over 20,000 baked beans in under five minutes.</description>
</item>

We can also add a publication date for the item, using the <pubDate> tag. This must be in the correct format: Sat, 07 Sep 2002 00:00:01 GMT. That is, the day in three letters; comma; the day of the month with a leading zero; the year in four digits; the time, including hours, minutes, seconds, all with leading zeros; the timezone. The result could be:

<item>
<title>New Bean Eating Record</title>
<link>http://www.example.com/beans/newrecord.html</link>
<description>A man has broken the bean eating record by eating over 20,000 baked beans in under five minutes.</description>
<pubDate>Thu, 03 Sep 2005 17:00:00 GMT</pubDate>
</item>

You can then add many more items in a similar fashion.