Anatomy of an RSS 2.0 Feed

The process of building an RSS 2.0 feed isn't complicated, but it does require that you understand the various elements and attributes defined in the RSS 2.0 specification. This chapter will take you through the components of an RSS feed, show how to use them, and highlight any best practices along the way. As you read, we will systematically construct an example RSS feed to illustrate what you have learned.

Note

Strictly speaking, the RSS 2.0 specification is imprecise at times. As a result, there can be various interpretations of how certain aspects of RSS should be implemented. This guide offers you a mainstream approach to RSS features wherever possible.

Learning by example is a great way to tackle RSS, so we'll use a hypothetical food web site called Seize Her Salad to walk through the building of a feed. Here is the scenario: The food mavens at Seize Her Salad want an RSS 2.0 feed to dish out their favorite recipe of the week. Before they invest a lot of programming time to generate a feed from their recipe database, they have decided to build one by hand to see what is involved.

We'll use this scenario as a case study to examine how to use the various features in RSS. (Be sure to check out the complete example feed at the end of this chapter.)

The RSS Document

Every RSS 2.0 feed is an XML document, so the very first line of our RSS feed must be an XML declaration. The XML declaration tells feed readers (and XML parsers in general) that what follows is ...

Get How to Build an RSS 2.0 Feed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.