Atom feeds are simply a collection of entries. The simplicity of Atom feeds is one of the things that makes Atom so great. But, by making use of XML extensibility, Atom feeds are much more powerful then their predecessor... RSS feeds. Atom Feeds can handle complex content and yet remain very simple and elegant on their own. They are not limited to just text, they may contain images, video, text, html, and more all at once!
Take a look at this Feed skeleton. The example is broken down into detail down below, showing both simple and more advanced concepts of a Feed for a fake blog.
<?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <!-- Feed Details --> <title type="text>Blog Title</title> <author> ... </author> <!-- First Entry --> <entry> ... </entry> <!-- Second Entry --> <entry> ... </entry> </feed>
For Atom feeds the root most element is the <feed>
tag. That tag points to the http://www.w3.org/2005/Atom
namespace. This is one of the most important parts of an Atom feed
and XML in general. By defining multiple xmlns XML
namespaces you can use tags from different namespaces within
your Atom Feed thereby extending Atom for enhanced functionality.
I suggest that you take a look at the
Atom Syndication Format specification to learn more about the individual tags
in more detail. The most common tags are <content>,
<author>, <title>, <id>,
<link>, and probably most importantly the
<entry> tag, which may itself incorporate all of the
previously mentioned tags!
Inside an Atom Feed, before any <entry> tags, will
be a bunch of data that describe the feed itself. This is metadata describing
the feed and is meant to be human readable and straightforward. It is simple
to understand and implement. The Atom Syndication Specification states that
this area must contain the following:
An
<id>tag - a unique identifier like a URLAn
<updated>tag - a recently updated timestampA
<title>tag - a human readable title0 or more
<author>tags - to indicate the feeds authors0 or more
<contributor>tags - similar to authors0 or more
<category>tags - to convey some information0 or more
<link>tags - for other resources/URLsAnd optional
<generator>,<icon>,<logo>,<rights>, and<subtitle>tags for extra information and details for the feed.
Each element is explained in detail under the atom:feed tag's documentation. Here is an example for a fake blog. Remember the required items are green and optional items are blue.
<?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <!-- Feed Details --> <title type="text">Overused Moleskin</title> <updated>2008-03-05T12:29:29Z</updated> <id>tag:example.org,2003:3</id> <link rel="alternate" type="text/html" href="http://example.org/"/> <link rel="self" type="application/atom+xml" href="http://example.org/feed.atom"/> <subtitle type="html"> My <em>short</em> stories. </subtitle> <rights>Copyright (c) 2008, Joseph Pecoraro</rights> <author> <name>Joseph Pecoraro</name> </author>
The blog is titled
Overused MoleskinIt is found at
http://example.org/Was last updated
2008-03-05Written and copyrighted by
Joseph PecoraroIt likely contains Joe's
short stories
There is really nothing to it! Everything is human readable. You can
see in the <subtitle> tag that its inner content
can be defined in a number of extensible ways. In the case of the
<subtitle> tag its values can be "Text Content" meaning
text, html, or xhtml, but you will
see later with the <entry>'s <content>
element, the data can be far different.
A feed is not complete without <entry> elements.
Go ahead to the next page for information regarding this key
Atom element.