Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Voices That Matter

Creating RSS Feeds

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Understanding an RSS Document

Let's begin by taking a look at an RSS 2.0 document. To create your own RSS document, you need to know the names of the various parts of such a document.

Start composing your RSS document by opening an RSS creator program such as NewzAlert Composer and giving your RSS feed a name—"Steve's News" in the example shown here (Figure 3.1). This is the RSS feed name that appears in the RSS reader (Figure 3.2).

Figure 3.1

Figure 3.1 NewzAlert Composer provides property information about your feed.

Figure 3.2

Figure 3.2 Here's the NewzAlert feed displayed in RSSReader.

The name of the actual RSS document is news.xml, and like all XML documents, this one starts with an XML declaration:

<?xml version="1.0" encoding="ISO-8859-1"?>
        .
        .
        .

The next line of code in the RSS document is called the document element because it contains all other elements in the document. Thus, it is here that the document specifies that its version is RSS 2.0.

<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
    .
    .
    .
</rss>

As you can see, the <rss> element looks much like the HTML elements you're already familiar with. (For more about how XML elements work, see Chapter 4.)

Inside the <rss> element is a <channel> element. A channel element, referred to as the channel in an RSS document, provides details about the feed you're creating.

<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
 <channel>
    .
    .
    .
 </channel>
</rss>

You'll see many different elements inside an RSS <channel> element. When you're creating your own RSS feeds using a tool like NewzAlert Composer, these are the elements you need to know about:

  • The <title> element contains the title of the feed. This is the name that will appear in the feeds window.
  • The <link> element contains a link for your feed. Usually this is a link to your home page for anyone reading your feed who wants more information.
  • The <description> element explains what your feed is all about.
  • The <language> element indicates the language the feed is in. For example, en-us means U.S. English (see Chapter 4).
  • The <image> element holds the URL of an image for your feed (see Figure 3.2).
  • The <copyright> element provides copyright information, if you want to add it.
  • The <managing Editor> element holds the name and/or email of the person responsible for the feed.

Here's what these elements for our news.xml code look like as stored by NewzAlert Composer:

<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
 <channel>
  <generator>NewzAlert Composer v1.70.6, Copyright (c) 2004-2005
   Castle Software Ltd, http://www.NewzAlert.com</generator>
  <lastBuildDate>Thu, 08 Dec 2005 14:01:27 -0500</lastBuildDate>
  <pubDate>Thu, 08 Dec 2005 14:01:34 -0500</pubDate>
  <title>Steve's News</title>
  <description><![CDATA[This feed contains news from
   Steve!]]></description>
  <link>http://www.rssmaniac.com/steve</link>
  <language>en-us</language>
  <copyright>(c) 2006</copyright>
  <managingEditor>Steve</managingEditor>
  <image>
   <title>Steve's News</title>
   <url>http://www.rssmaniac.com/steve/Image.jpg</url>
   <link>http://www.rssmaniac.com/steve</link>
   <description>Steve's News</description>
   <width>144</width>
   <height>36</height>
  </image>
    .
    .
    .
 </channel>
</rss>

Each of the items in the feed is stored in an <item> element. An <item> element contains these elements:

  • The <title> element is the text that will appear in the titles window of an RSS reader.
  • The <description> element will appear in an RSS reader's description window when the user clicks the item's title in the title window.
  • The <pubDate> element holds the date the item was published.
  • The <link> element holds the URL to get more information about the item.

Here's what these elements look like in the single <item> element:

<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
 <channel>
  <generator>NewzAlert Composer v1.70.6, Copyright (c) 2004-2005
   Castle Software Ltd, http://www.NewzAlert.com</generator>
  <lastBuildDate>Thu, 08 Dec 2005 14:01:27 -0500</lastBuildDate>
  <pubDate>Thu, 08 Dec 2005 14:01:34 -0500</pubDate>
  <title>Steve's News</title>
  <description><![CDATA[This feed contains news from
   Steve!]]></description>
  <link>http://www.rssmaniac.com/steve</link>
  <language>en-us</language>
  <copyright>(c) 2006</copyright>
  <managingEditor>Steve</managingEditor>
  <image>
   <title>Steve's News</title>
   <url>http://www.rssmaniac.com/steve/Image.jpg</url>
   <link>http://www.rssmaniac.com/steve</link>
   <description>Steve's News</description>
   <width>144</width>
   <height>36</height>
  </image>
    <item>
     <title>Steve shovels the snow</title>
     <description><![CDATA[It snowed once again.
      Time to shovel!]]></description>
     <pubDate>Thu, 08 Dec 2005 08:39:51 -0500</pubDate>
     <link>http://www.rssmaniac.com/steve</link>
    </item>
 </channel>
</rss>

Now that you have an overview of how an RSS 2.0 document works, it's time to start creating an RSS feed.

  • + Share This
  • 🔖 Save To Your Account