Video-Based Tutorial: Page (1) of 1 - 04/28/10 Email this story to a friend. email article Print this page (Article printing at page facebook

Real-World XML: Part 5 of 12

Enriching the RSS feed By Joe Marini

XML technologies offer web developers and designers more flexibility than ever before. In Real-World XML, industry expert Joe Marini covers the best programming practices with XML, including the tools needed to build effective XML structures. He demonstrates the implementation of XML formats, how these formats work in real-world situations, and how they can facilitate project planning and development. Exercise files accompany the course.

XML Essential Training is a prerequisite for getting the most out of this course.

Topics include:

  • Understanding the Sitemap index format
  • Integrating XML and design
  • Using XML effectively in Firefox and Internet Explorer
  • Avoiding common design mistakes
  • Understanding and implementing DOM algorithms
  • Building an XML tag set
  • Using XML with RSS and Atom
  • Processing XML data with XSLT

Okay, let's continue our coverage of the RSS file format by taking a look at some of the optional elements of the Channel tag.

Now, this is not an exhaustive list. If you want to see every single tag that the channel can possibly contain, I urge you to refer to the specification at the URL I provided earlier. These are just a selection of some of the more important tags that you should know about.


So the Language tag starting right here at the top indicates the language that the feed is written in. This is written using the W3C style language indicators. So for example, en-us indicates English in the United States, and you can look up a whole bunch of these language codes on the W3C's website.

The Generator tag indicates the software package that created the feed and in this case, I have got an example here called MyRSSPackage 2.0. But if you edit it by hand, you can also just simply include the string by hand.

The Image tag specifies an image that can be displayed with the channel, and there are typical constraints on the size that this image can be, and what you refer to the spec for that, it is not very big. It'd simply be like 140 pixels high by 80 pixels wide or something like that.

The Copyright tag is the copyright notice for the channel content. So if you want your information to be copyrighted, you can put a copyright notice in using this tag.

Click Play or press spacebar to start or stop video

The Publication date for the channel content is indicated by the pubDate field. Now, this is a date field that indicates what date that the publication happens on. So for example, if you publish this everyday, then this date would flip every 24 hours.

The Category tag indicates the category for the news and you can use as many category tags as you want. So here I have got one example for news, but if you had a channel that fit into more than one category, you can use as many of these category tags as you feel adequately describes the categories your feed fits into.

Then there's the lastBuildDate. The lastBuildDate is different from the pubDate.

This is the last time that the channel content changed. So you may publish on a regular schedule and the content may change on a different schedule. So then, you don't necessarily need to do the same thing.

The last tag I'm going to point out which is optional for the channel is the Rating tag, which is the rating for the channel and this conforms to the PICS standard which is specified by the W3C, and it's described at this URL right here. So if you want to learn more about that, you can investigate that URL.

The Item tag also has optional elements. The author, right there at the top, that indicates the person who wrote this particular item and the email address of the author. So for example, each individual item can have a separate author.

This is what the content will look like. In this case, it is
The Category indicates the category for this item. So just as you can have categories for the Channel tag, you can also have categories for an individual item, and again, you can use more than one here.

The pubDate is the publication date for this particular item. So this is the date at which time this particular piece of information was published and added to the feed.

The next field is interesting. It is called guid. A guid means a globally 03:34 unique identifier and it is an identifier that is unique for this item. There are no rules for the format of guids. You can use anyone of a number of schemes. Though they usually take the form of URIs or URLs.

If they have an optional attribute named is PermaLink = "true", then the blog reader or the feed reader to be more specific can assume that the guid can be used to open a link to the item in the browser.

Then finally, there's the Enclosure optional element which describes a media object that is attached to the item. This is how podcasting is achieved. There are three required attributes if you are going to use the enclosure.

There is a URL attribute which indicates where the item is located on the Internet and you can see I have got an example over here. So for example, if I was creating a podcast and I was creating mp3 files, for each item I would use an enclosure tag which specify the URL to the mp3 file.

There is the Length, which is the size of the item in bytes. So I have got that here and then the MIME type of the item, which in this case would be audio MPEG. But it could be anything else based upon what the content of the information is. It might be some other audio file format or video or what have you.

So now, let's go back and take a look at our RSS sample feed, because now we have much richer information that we can include in the feed format. So here we have the RSS and Channel tags that we started out with and the title link and description which are the required parts of the channel definition.

Well, that now we have also added the optional language here, specified as US English and the generator. I've put in this By Hand because I don't have a software package that made this one, and the publication date. The publication date was Wednesday, 5th of March, 2009 at 2 AM.

So far this feed only has one item in it and again, we have added some more rich information here. Rather than just the title link and description, there's also a pubDate and author and a guid which happens to be a PermaLink.

So let's talk a little bit about including HTML content in RSS feeds. There's a couple of ways that you can achieve doing this. I'm going to talk about the two most common. Now, as I said earlier, the RSS specification for RSS 2.0 allows HTML to be included in the Description tags of items and channels.

In order to make this work however, you can just simply shove HTML code with all of its angle brackets and everything inside the RSS file. You have to encode the HTML before you put it in.

Now, the first way of doing this is encoding the HTML tags by doing what is known as escaping. You can see here that I have got the entity encoding for the less than sign, and then a bold and then a greater than sign, and over here, I have got another bold tag.

If you look at this in HTML, this < would be a left-angle bracket like it on this description right here and then this > would be the greater than angle bracket. So I have entity encoded the HTML here, and included it in the Description tag.

The other way to do it is to leave the HTML just as it is, but put it within what is known as a CDATA section. CDATA sections are standard parts of XML and they are declared by using an angle bracket with an exclamation point, a bracket, the word CDATA, and then another opening bracket.

And then you can just put your HTML code right here inside the CDATA section and then close it off by two brackets and an angle bracket.

The CDATA section basically tells the XML parser that's reading the XML feed, don't worry about what is in here. It is character data. You don't have to worry about parsing it. You can just skip over it for the purposes of trying to find tags.

Okay. Well, now we know enough to create our own RSS feeds. Let's move on now and take a look at our next real-world XML file format, which is the Atom file format.

About is an award-winning provider of educational materials, including Hands-On Training instructional books, the Online Training Library, CD- and DVD-based video training, and events for creative designers, instructors, students, and hobbyists.

The Online Training Library and CD-ROM titles include such subjects as Photoshop, Flash, Dreamweaver, Illustrator, Office, digital photography, Web design, digital video, and many others.'s all-star team of trainers and teachers provides comprehensive and unbiased movie-based training to an international membership of tens of thousands of subscribers. Considering the speed at which technology evolves, the Online Training Library is a great solution for keeping your skills current. Library subscriptions begin as low as $25 a month, with no long-term commitment required.

Page: 1

Joe Marini is the director for Microsoft's Visual Studio Industry Partner program, and has been active in the Web and graphics industries for more than 15 years. He was an original member of the Dreamweaver engineering team at Macromedia, and has also held prominent roles in creating products such as QuarkXPress, mFactory's mTropolis, and Extensis QX-Tools. He is regularly a featured speaker at industry conferences and has authored or co-authored several books on Web development. His book The Document Object Model is widely regarded as the definitive resource for working with the DOM.


Related Keywords:xml, Extensible Mark-Up Language, xml training, xml tutorial, xml techniques, xml design, web design, web site design


Our Privacy Policy --- @ Copyright, 2015 Digital Media Online, All Rights Reserved