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

Real-World XML: Part 4 of 12

Using required and optional elements in RSS feeds 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 setUsing XML with RSS and Atom
  • Processing XML data with XSLT

Using required and optional elements in RSS feeds

RSS feeds are composed of a collection of XML tags and some of them are required and some of them are optional. Now, all RSS feeds that have the version 2.0 as their version number have the RSS tag as their root. That goes along with the version attribute that contains the string 2.0, which clearly identifies the file as an RSS version 2.0 feed.


Each RSS tag contains in turn a single Channel tag, and this is where the content of the RSS feed goes. So if we were to start building a Bare-Bones RSS feed, it would look something like this. We would have the RSS tag at the top with the version being 2.0, and then we would have a Channel tag inside the RSS tag.

Now, this is a Bare-Bones RSS feed and it doesn't do anything at all. So we have to figure out how to add some content to it. Now, the Channel tag itself has some required elements and the required elements of the Channel tag are the title and this refers to the name of the channel.

So for example, if you have an HTML website and that website contains the same information as your RSS file. In other words, your RSS file is just a syndicated version of the content on your site, then the title of the channel should be the same as the title of the website and I've provided an example over here.

Click Play or press spacebar to start or stop video

So if I have my website and I named the website Joe's news and information, if I had an RSS feed that provided essentially the same information as the site, I would name it the same name.

On the other hand, if you have RSS feeds that provide more specialized information, for example, if you have an RSS feed that lists the number of times that you will be speaking in an upcoming given period of time or publications you've put out and when that happened, or places you have been to for lunch, and what dates you went. Then obviously you are free to name those other names. But name your RSS feed that provides the same information as your site, the same name as your site.

The Link tag is also required. The Link tag provides a URL which indicates the HTML website that corresponds to the channel. So for example, if I had an RSS feed that correspond to my website and my website was, I would place that URL in there as well.

Then finally the Description tag is also required, and this is a short description, a sentence or two, maybe three describing the channel. So if we were to update our previous example code using what we now know, the RSS feed will start to look like this. So we would have the RSS and Channel tags that we had before, and we would have the title link and Description tags.

Now, this is beginning to look a little bit more like a real RSS feed, but not exactly very useful because it doesn't contain anything except for the information about the channel. In order to make this RSS feed useful, we have to add item tags to it, and item tags go inside the channel, and they specify information about each individual piece of syndicated content, and that's what we see here.

So each item tag also has a set of sub- tags or child tags that are required or optional. So the tags I have listed here and technically speaking, all of the tags specified for item are optional. However, at least one title or one description has to be present.

So the Title tag, right here, that is the title of the individual item, and I have provided an example. So one item might be named Joe goes to the movies, and the link which is a URL to that item, this is a URL that a feed reader can use to open up the larger piece of syndicated content.

In this case, it might be something like URL to my website and then JoeAtTheMovies.html, and the Description tag which contains a sentence or two or three or so which describes the content of the item. In this case, it's just a short description. Here is what I saw at the movies last weekend.

Now, just a quick note. According to the RSS 2.0 specification, the Description tag is allowed to have HTML content in it, and since you are going to be embedding HTML content inside XML file, you have to do some special encoding, and I'll cover that later.

If we were to now take our RSS feed and apply what we now know, it would look something like this. We have our RSS tag, we have our Channel tag, we have got the tags up here which describes the channel, and then we have a couple of items. So this item here is Joe goes to the movies. It has got a link, and a description, and this item here is Joe has lunch, and there's the link and description of what I had for lunch.

This here is actually a fully formed and proper RSS feed. Again, it is not particularly rich or useful because it doesn't contain things like publication dates or information about authors and so on, and we'll cover that more in the next section when we see more of the RSS 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

To Comment on This Article, Click HERE

Most Recent Reader Comments:
  • Real-World XML: Part 4 of 12 by DMN Editorial at Apr. 26, 2010 7:20 am gmt (Rec'd 1)

    Click Here To Read All Posts
    Must be Registered to Respond (Free Registration!!!, CLICK HERE)
  • -->

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