– Common Function Library Project

cfRssFeed(feedURL[, amount])

Last updated November 20, 2008


Jose Diaz-Salcedo

Version: 2 | Requires: CF6 | Library: StrLib

This UDF display's a rss feed to a web browser, in a readable format.

Return Values:
Returns a query.


<cfinclude template="rssfeedUdf.cfm">

<cfset rssFeed = cfRssFeed("")>

<font face="arial" size="2">
<cfoutput query="rssFeed">
  <li><b><a href="#link#">#title#</a></b> - #description#</li><br>


Name Description Required
feedURL RSS URL. Yes
amount Restricts the amount of items returned. Defaults to number of items in the feed. No

Full UDF Source:

 Display rss feed.
 Changes by Raymond Camden and Steven (v2 support amount)
 @param feedURL 	 RSS URL. (Required)
 @param amount 	 Restricts the amount of items returned. Defaults to number of items in the feed. (Optional)
 @return Returns a query. 
 @author Jose Diaz-Salcedo ( 
 @version 2, November 20, 2008 
<cffunction name="cfRssFeed" access="public" returntype="query" output=false>
	<cfargument name="feedUrl" type="string" required="true"/>
	<cfset var news_file = arguments.feedurl>
	<cfset var rss = "">
	<cfset var items = "">
	<cfset var rssItems = "">
	<cfset var i = "">
	<cfset var row = "">
	<cfset var title = "">
	<cfset var link = "">
	<cfhttp url="#news_file#" method="get" />
	<cfset rss = xmlParse(cfhttp.filecontent)>

	<cfset items = xmlSearch(rss, "/rss/channel/item")>
	<cfset rssItems = queryNew("title,description,link")>

	<cfloop from="1" to="#ArrayLen(items)#" index="i">
		<cfset row = queryAddRow(rssItems)>
		<cfset title = xmlSearch(rss, "/rss/channel/item[#i#]/title")>

		<cfif arrayLen(title)>
			<cfset title = title[1].xmlText>
			<cfset title="">

		<cfset description = XMLSearch(items[i], "/rss/channel/item[#i#]/description")>

		<cfif ArrayLen(description)>
			<cfset description = description[1].xmlText>
			<cfset description="">

		<cfset link = xmlSearch(items[i], "/rss/channel/item[#i#]/link")>

		<cfif arrayLen(link)>
			<cfset link = link[1].xmlText>
			<cfset link="">

		<cfset querySetCell(rssItems, "title", title, row)>
		<cfset querySetCell(rssItems, "description", description, row)>
		<cfset querySetCell(rssItems, "link", link, row)>


	<cfreturn rssItems />

blog comments powered by Disqus


Latest Additions

Kevin Cotton added
May 5, 2016

Raymond Camden added
April 25, 2016

Chris Wigginton added
January 18, 2016

Gary Stanton added
November 19, 2015

Sebastiaan Naafs - van Dijk added
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson