Hello everyone, I wanted to write a tutorial explaining how to use XML/RSS feeds you see all over the place these days (specially on Blogs such as BlogColony.Com).

Let's begin:

First we need to define where the XML/RSS feed is located on the web, this is the direct URL to it:

  URLToPull  = "http://www.easycfm.com/syndication/mostviewed.cfm";

The next step is to actually do a CFHTTP to the location you specified, this is how you get the values of the XML/RSS from the site you want (in this case, the 5 most viewed EasyCFM.Com Tutorials):

<cfhttp url=

Here, first let's define a variable called XMLContent and assign the returned value of CFHTTP to it, next let's trim() it to ensure that the XML is correctly parsed by the line below that.
  XMLContent = trim(cfhttp.filecontent);
  XMLContent = XMLParse(XMLContent);

Now, let's actually output the information about the feed, in this case the site logo, title and description:
    Feed provided by:<BR>
    <a href="#XMLContent.rss.channel.image.link.xmlText#">
       <img src=
"#XMLContent.rss.channel.image.url.xmlText#" alt="#XMLContent.rss.channel.image.title.xmlText#" border="0">

Now we will use the array value "XMLContent.rss.channel.item" which will let us know how many records we want to process and display:
<cfloop from="1" to="#ArrayLen(XMLContent.rss.channel.item)#" index="idx">
 <a href=
 #ParagraphFormat(ReplaceNoCase(XMLContent.rss.channel.item[idx].description.xmlText, "&lt;", "<", "ALL"))#
 Author: #XMLContent.rss.channel.item[idx].author.xmlText#<BR>
 Date: #XMLContent.rss.channel.item[idx].pubDate.xmlText#

Last, let's display the actual copyright notice that the feed itself returns:
<cfoutput><div align="center">#XMLContent.rss.channel.copyright.xmlText#</div></cfoutput>

And that's pretty much it...

Remember that you can also do this if you are stuck along the way:

<cfdump var="#XMLContent#">

That will dump out the XML file and that will allow you to see what you're doing.

You can go entering data in the CFDUMP tag as follows:
<cfdump var="#XMLContent#"> - This till show you the main XML document.
<cfdump var="#XMLContent.rss#"> - This will take you into the RSS branch
<cfdump var="#XMLContent.rss.XMLChildren[1]#"> - this will take you into the first child branch of the rss section.

and so forth, you can work your way down to each individual item in the feed.

Questions? Comments? Let me know...

About This Tutorial
Author: Pablo Varando
Skill Level: Advanced 
Platforms Tested: CFMX,BlueDragon
Total Views: 164,229
Submission Date: December 27, 2003
Last Update Date: June 05, 2009
All Tutorials By This Autor: 47
Discuss This Tutorial
Sponsored By...
Mobile App Development (IOS, Android, Cordova, Phonegap, Objective-C, Java) - Austin, Texas Mobile Apps - Touch512, LLC.