RSS and Atom in Action: Newsfeed Formats | Part 2 | WebReference

RSS and Atom in Action: Newsfeed Formats | Part 2


RSS and Atom in Action: Newsfeed Formats
Part 2

4.5 The new standard: Atom

In 2003, a group of bloggers who were disillusioned with the state of newsfeed and publishing API standards came together to create a new standard, which would later be known as Atom. They wanted to start fresh and do things right this time. Because the group was led by well-known bloggers and XML experts Joe Gregorio, Mark Pilgrim, and Sam Ruby, it attracted the attention and involvement of all the major blog server developers.

The Atom group hoped that by including all the right people, building on existing HTTP and XML specifications, and creating carefully worded complete specifications, they could build a better newsfeed format and publishing protocol. In 2004, they joined with the Internet Engineering Task Force ( IETF) and created the Atom Publishing Format and Atom Publishing Protocol. In 2005, IETF released Atom as an Internet standard known formally as RFC-4287 Atom Syndication Format.

Whether you think Atom is an improvement over RSS or just another format, as a blog application developer you'll need to learn Atom. All the major blog servers either support Atom now or have plans to do so, and, one of the largest blogging services, offers only Atom newsfeeds—no RSS.

4.5.1 Atom by example

Let's take a look at an example. Listing 4.3 shows a typical Atom newsfeed with one news item. Items are known as entries in Atom lingo.

The newsfeed shown in listing 4.3 is unlike those we've seen before. Gone are the <rss>, <channel>, and <item> elements found in RSS. In Atom, they've been replaced by <feed> [line 2] and <entry> [line 12].

An Atom feed must specify a <title> [line 3], a <link> [line 4] to the source web site, the most recent instant when the feed was updated [line 7], and the <author> [line 8] (unless the author is specified for each entry). The feed includes a <link> element with rel="self", which contains the URL of the newsfeed [line 5].

Each Atom entry must specify a <title> [line 13], at least one <link> [line 14], and an <id> [line 15]. The entry in listing 4.3 contains both a <published> [line 16] and an <updated> [line 17] date, but only the updated date is required. Note that these and all other dates in Atom conform to RFC 3339, which allows the ISO 8601 date format.

An entry may contain one <content> element. In listing 4.3, the <content> element [13] is marked as type="xhtml" because it contains XHTML (as opposed to escaped HTML, as we've seen in the previous newsfeed examples).