How to Create an RSS Feed from Your ColdFusion Page
The ColdFusion scripting language exists alongside HTML to create dynamic Web pages that can retrieve data from databases and create interactive forms. One of these interactive elements is the Really Simple Syndication reader, which uses an XML standard to deliver data such as blog posts and site updates in an organized way. Using the cffeed tag in ColdFusion you can build an RSS feed from your databases for users to subscribe to.
Instructions
-
-
1
Build a query to the database from which the RSS feed will get its data:
<cfquery name="feed" datasource="stories">
SELECT * FROM stories
</cfquery> -
2
Map the table data to a structure you will use for the feed:
<cfset mappedStruct = StructNew()>
<cfset mappedStruct.publisheddate = "published">
<cfset mappedStruct.content = "story">
<cfset mappedStruct.title = "Title">
<cfset mappedStruct.rsslink = "storylink"> -
-
3
Create a meta object for the RSS feed, to contain the meta data for the feed:
<cfset meta.title = "Title">
<cfset meta.link = "http://storylink">
<cfset meta.description = "Top Stories">
<cfset meta.version = "rss_2.0"> -
4
Create the feed with the cffeed tag:
<cffeed action="create"
query="#feed#"
properties="#meta#"
columnMap="#mappedStruct#"
xmlvar="rssXML">
-
1