Creating the newsfeeds is pretty straight-foward as long as the feed is correctly formated. You can get any server-side scripting language to generate a feed for you. Below is a code that generates the feed of my articles. Two files will needed - a coldfusion component (get_articles.cfc) dealing with executing a SQL query and create_feed.cfm which obviosuly creates a feed. You may also create a blank articles.xml file that the results will be saved to. I split the code into a few parts, as it's easier to explain how the code works. It's a very simplyfied version however it works quite well and may help to understand the idea.

<cfcomponent output="false">

<cfset DSN = "---your datasource name---">

<cffunction name="get_articles_function" output="no"

// you may specify some additional arguments
with a addition of if statementsto make this
component truly reusable

<cfquery name="get_articles" datasource="#DSN#">
SELECT articleID, atricle_title, article_content, author, date
FROM articles

<cfreturn get_articles>



Following part will generate a properly formated header of the feed:


<cfinvoke component="-path to the previosuly created component-"
method="get_articles" returnvariable="articles">

<cfsetting enablecfoutputonly="yes">
<cfsavecontent variable="theXML">

<?xml version="1.0" encoding="ISO-8859-1" ?>

<rss version="2.0">

<title>Articles - Blue and Orange</link>
<description>Blue and Orange - coolest web development blog</description>

<lastBuildDate>#dateformat(now(), "ddd, dd mmm yyyy")#
#timeformat(now(), "HH:mm:ss")</lastBuildDate>

Article title given in url must not contain any spaces, in this case spaces will be replaced by _.


function generate_correct_title(title) {

title = replace(title, " ","_","ALL");

return title;


Cfloop will now produce an <item> object for every record in a database

<cfloop query="articles">


<cffile action="write" file="#expandPath(".")#articles.xml" output="#theXML#">

<h1>Feed has been created!!!</h1>

Tagged: RSS  coldfusion