Simple RSS to CF Query

This quick and easy function converts an RSS feed XML document into a coldfusion query for you to easily loop through and use on your website.

Files Included in this ZIP (download zip file)
rssFeed.xml An example RSS feed for this tutorial
xml.cfc CFC containing the function required
queryDump.html Dump of the resultant CF Query

1. Use CFHTTP to obtain the XML packet.
2. Then make sure it’s a valid XML packet
3. Simply invoke the CFC method and pass the function the parameters required as listed below:
• xmlPacket: A valid XML packet returned from the RSS Feed
• parentTree: The parent tree item in the RSS XML Feed
• childElement The child item containing the appropriate data required

The data will be returned to you in a CF query with the column names named exactly the same as the XML tree items.

//Get your RSS Data as you normally would
<cfhttp url=""

// Make sure it’s a valid XML Packet
    xmlContent = Trim(cfhttp.filecontent);
    xmlContent = XMLParse(xmlContent);

// Method call to convert XML into CF query
<cfinvoke component="xml.cfc"
<cfdump var=

In Action

If you use the exact code above, it will fetch the RSS feed as seen in the included file (rssFeed.xml). It will then return the query as seen in the included file (queryDump.html).


About This Tutorial
Author: Paolo Broccardo
Skill Level: Beginner 
Platforms Tested: CFMX7
Total Views: 106,116
Submission Date: March 28, 2006
Last Update Date: June 05, 2009
All Tutorials By This Autor: 1
Discuss This Tutorial
  • OK, the code in this tutorial is NOT the way to learn CF. Evaluate() is unnecessary in CFMX (certainly for this code). This kind of thing should be The elements like media:content aren't valid query column names, so you need to replace the colons with something like this: And finally, a number of blank entries come from this: because instead of counting the elements we actually want we're counting all children of the main feed element. It should be:

  • Hi, can we remove rows with [empty string] result from the end result?How can we do this? Thanks

  • i'm digging for a way to get xml to a query so i can paginate through it... this was as close as i've gotten and it looks like this thread hasn't been active in almost 4 months... just wondering if anyone solved this? TIA, greg

  • I had a parser similar to this running on my site but switched from TypePad's rss to Feedburner's feed ... and the link, instead of being like this: THISLINK is like this in the XML. So of course this is returning a blank on my URL. Any ideas? I swear I have been searching all night here ...

  • I get this error with some feeds "The column name "media:content" is invalid." Could you recomend some cfc code to account for this?

  • The problem is most likely with how you are calling the component. In the example it says: The first part can be somewhat misleading. You don't use the .cfc first off. Second, you need to put the exact path the file is found off of your wwwroot. For instance, my xml.cfc file is stored in the folder misc, so my tag looks like this: There is a working example of it here:

  • i am sure it is something trivial. Author - please help!

  • I get the same error

  • I got the following error when I tried this code: Could not find the ColdFusion Component xml.cfc. Please check that the given name is correct and that the component exists. The error occurred in C:\CFusionMX\wwwroot\cfdocs\getting_started\my_app\RSS Feeds\rssQuery\Proquestrss.cfm: line 21 19 : method="xmlToQuery" 20 : xmlPacket="#xmlContent#" 21 : parentTree="" 22 : childElement="item" 23 : returnVariable="qXML">


Website Designed and Developed by Pablo Varando.