The four main sections of an RSS file
After the root element come the four main sections of the RSS file. These are the channel, image, item, and text input sections. In practical use, the channel and item elements are requirements for any useful RSS file, while the image and text input are optional.
The channel section
The channel element contains metadata that describe the channel itself, telling what the channel is and who created it. The channel is a required element that includes the name of the channel, its description, its language, and a URL. The URL is normally used to point to the channel's source of information.
Listing 3 shows the beginning of the channel element. This part of the channel element defines the channel and begins the channel information.
|
The channel element contains the remaining channel tags, which describe the channel and allows it to be displayed in HTML. The title can be treated as a headline link with the description following. The Channel Language definition allow aggregators to filter news feeds and gives the rendering software the information necessary to display the language properly.
The </channnel>
tag is used after all the channel elements to close
the channel. As RSS conforms to XML specs, the element must be well formed;
it requires the closing tag.
You can include nine optional tags in a 0.91 channel definition. Some examples are PICS Rating, Copyright Identifier, Publication Date, and Webmaster. You can use these additional elements for a variety of purposes. For example, sites that aggregate content can use this additional meta information to allow users to filter news feeds on the basis of Platform for Internet Content Selection (PICS) ratings. For additional information on other Channel tags, look in the RSS specifications.
The image section
The image element is an optional element that is usually used to include the logo of the channel provider. The default size for the image is 88 pixels wide by 31 pixels high, but you can make your logo as large as 144 pixels wide by 400 pixels wide. Here is a sample image element:
|
The image's title, URL, link, width, and height tags allow renderers to translate the file into HTML. The title tag is normally used for the image's ALT text. Keep the image to 88 x 31 or smaller if possible, because many renderers translate channels into fixed width tables as narrow as 100 pixels. Larger graphics could cause the tables to break inappropriately, or cause your image to be left out when displayed.
The items
Items, the most important elements in a channel, usually form the dynamic part of an RSS file. While channel, image, and text input elements create the channel's identity and typically stay the same over long periods of time, channel items are rendered as news headlines, and the channel's value depends on their changing fairly frequently. Here is an example of a channel item:
|
Fifteen items are allowed in a channel. This is a reasonable limitation, because most people use channels to distribute recent Web content. Titles should be less than 100 characters, while descriptions should be under 500 characters. The item title is normally rendered as a headline that links to the full article whose URL is provided by the item link. The item description is commonly used for either a summary of the article's content or for commentary on the article. News feed channels use the description to highlight the content of news articles, usually on the channel owner's site, and Web log channels use the description to provide commentary on a variety of content, often on third-party sites.
Much of the beauty of the RSS format lies in the item element. As you can see from the above example, items are easy for developers to define and easy for users to read.
The text input
The text input area is an optional element, with only one allowed per channel. Usually rendered as an HTML form, text input lets the user respond to the channel. You might use this feature to enable your users to subscribe to your newsletter or search your site. Here is an example of a text input element:
|
The title is normally rendered as the label of the form's submit button, and the description as the text displayed before or above the input field. The text input name is supplied along with the contents of the text field when the submit button is clicked.
These are the four main elements of an RSS file. After adding the image,
item, and text input elements, remember to close the channel with the </channel>
tag and the RSS file with the </rss>
tag.
The proposed RSS 1.0 specification introduces modules, which will allow RSS to be extended to accommodate additional information without rewriting the specification. For example, you could write a module to add rich media to your channel for broadband clients while standard clients would still see headlines and descriptions. You may want to learn more about modules so that you can take advantage of them once the 1.0 specification is implemented.
View An introduction to RSS news feeds Discussion
Page: 1 2 3 4 5 6 Next Page: Now start working with RSS files