The Controversial CDATA programming construct has caused somewhat of a love-hate relationship among RSS programmers. What is CDATA? Well to put it in very easy terms, it allows us to place within the description sub-element of Item, HTML commands and language. In other words it extends the description by allowing us to create links, references and the like within what is purely a text element created to describe the item. Remember that within the Item element, the sub-element of description will look like this.
<description>Here is where I describe the item in my RSS feed</description>
Let us say I want to extend this piece and I wanted to get a Bold command with the <b> </b> tags; or Italics with the <i> </i> tags command or something else within it. Or perhaps I would want to place a break in the lines <br> dividing it up? Or maybe I want to get more sophisticated? Let me give you an example.
Remember Randy Pandy and his Perfumery at randypandy.com? Well now not only does his wife Sandy want to describe the HeavenScent Skunk Perfume but she wants a picture of the bottle with the description. So, hold on, you say. Easy as pie. Use the enclosure command. Well right and not right. Sure you can put a picture of the perfume bottle in the enclosure command, but it will NOT appear WITH the description. It will appear alone and then the user will have to read the description. So while this is GREAT for audio and video a plain visual that I want next to a description kind of gets left alone if I just put in an enclosure. So we have the description, and for the sake of all I will repeat it here.
<description> Heaven Scent Perfume the Smell your lover will die for. Created especially by Skunk Perfumes it is their newest and best selling perfume on the market today. Purchase a beautifully shaped skunk bottle with this incredible perfume and get a whopping 50% off! And if you purchase over $100 we will throw in Free overnight delivery as well! </description>
Okay now Sandy wants a picture to go right into that description and when the user sees the text in their aggregator they will also get a
visual. Thus the CDATA command. First lets look at it in action and then we will explain.
<description> [CDATA[<img border="0" src="http://www.randypandy.com/perfumes/heaven.JPG" width="138" height="180"/></a><p>
Heaven Scent Perfume the Smell your lover will die for. Created especially by Skunk Perfumes it is their newest and best selling perfume on the market today. Purchase a beautifully shaped skunk bottle with this incredible perfume and get a whopping 50% off! And if you purchase over $100 we will throw in Free overnight delivery as well! </p><p>randypandy.com - All Perfumes You Can Ever desire </p> </p><br clear=all>]] </description>
Notice first what we did? First we set the tag description. Then within it immediately we tell the file "Hey get ready for some good old HTML", and thus we add the [CDATA[ Next we want our picture of the perfume. So for those of you who know HTML this is simple. We give it the image information.
<img border="0" src="http://www.randypandy.com/perfumes/heaven.JPG" width="138" height="180"/></a>
After that we continue with our description. Get in a few line breaks with either the <p> </p> or <BR> </BR> constructs. Then
finally before the end we close it off with ]] tag.
You can get fairly sophisticated with CDATA. The thing is many programmers do NOT like it, as it allows too many rooms for mistakes, and it is a throwback to old HTML. The purity of the XML is kind of compromised here. But it serves a purpose and allows us to get a picture with the words, which is incredibly important. Many, many RSS feeds use it, and it is a very useful tool to get the "picture" across to the user. You can combine it as well with enclosure, to get an audio out, a description, and say a picture of the Album. In other words a full media experience of text + picture + audio.
Well that is it. Our next article will put it all together and give you a look at the final well formed XML file which will act as our template for rss.xml. It will lay it all out for you with a couple of items, so you can grab it and use it for your RSS feed.
Previous Articles In This Series:
- The Basics of Blogging and Web Site Creation - Part One: Content Is King
- The Basics of Blogging and Web Site Creation - Part Two: Introduction To Keywords
- Part Three - Keywords, Tags, Categories - Oh Vey! I Am So Mixed Up!
- Blogging & Website Basics - Part Four: So How The Hell Do I Get Bonafide Links To My Blog?
- Blogging - Part Five: Trying to Understand the Psychology Behind It All
- Blogging - Part Six: Viral Technology - An Introduction
- Blogging - Part Seven: Article Submission As A Tool To Extend Your Reach
- Basics Of Blogging Series - Part Eight: Using Email As An Advertising Tool
- Basics of Blogging Series: Part Nine - RSS Mania Addiction An Introduction To RSS and the Terminology
- Basics of Blogging Series: Part Ten - Outline of How to Create an RSS Feed
- Basics of Blogging Series: Part Eleven - Debunking a Few RSS Myths
- Basics of Blogging Series: Part Twelve - The RSS Feed Template File
- Basics of Blogging Series: Part Thirteen - The Basic Elements in the "Channel" Element
- Basics of Blogging Series: Part 14 - How the RSS Feed Works & Some Programming Constructs
- Basics of Blogging - Part 15 - Editor Tools - Qumana & Performancing Extension for Firefox
- Basics of Blogging - Part 15A - Qumana's Drop Pad
- Basics of Blogging Series: Part 16 - RSS Channel Sub-Elements Specifically "Image" (& How To Use It)
- Basics of Blogging Series: Part 17 - RSS - The Elements Within the "Item" Element
- Basics of Blogging Series: Part 18 - RSS - Podcasting, VideoCasting & The Magic of the Enclosure Sub-Element
Click Here For The Cumulative Index To All Posts @ Cobwebs Of The Mind
Tags: email, technology, blogging, web site creation, content, writing, books, Search Engines, SEO, site rank, page rank, RSS, Podcast, VideoCast
Categories: technology, internet, Basics of Blogging Series, What Is RSS Series
Basics of Blogging Series: Part 19 - RSS - Rounding Out The Multi-Media - The CDATA Command
No comments:
Post a Comment