– 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 />



Latest Additions

Raymond Camden added
November 04, 2017

Leigh added
May 11, 2016

Raymond Camden added
May 10, 2016

Kevin Cotton added
May 05, 2016

Raymond Camden added
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson