Do you know how to generate RSS Feed with ColdFusion MX? If you don’t know well about CFMX, it might be complicated and fussy. But you little know about XML technology, it’s quite simple.
<CFQUERY NAME=”RssQry” datasource=”MyDSN”>
SELECT *
FROM RssTable
WHERE Rss_status = <cfqueryparam cfsqltype=”CF_SQL_INTEGER” null=”no” value=”1″>
ORDER BY Rss_id
</CFQUERY>
<cfsavecontent variable=”theXML”>
<cfoutput><?xml version=”1.0″ encoding=”ISO-8859-1″ ?>
<rss version=”2.0″>
<channel>
<title>RSS</title>
<link>http://www.rss.com</link>
<description>This is Description</description>
<language>en-us</language>
<copyright>Copyright — .</copyright>
<docs>http://—–.com/rss/</docs>
<lastBuildDate>#dateformat(now(), “ddd, dd mmm yyyy”)# #timeformat(now(), “HH:mm:ss”)# EST</lastBuildDate>
</cfoutput>
<cfloop from=”1″ to=”#RssQry.RecordCount#” index=”ctr”>
<cfscript>
title = replace(RssQry.Rss_title[ctr], “<”, “<”, “ALL”);
description = replace(RssQry.Rss_description[ctr], “<”, “<”, “ALL”);
description = replace(description, “&”, “&”, “ALL”);
description = replace(description, ‘”‘, “‘”, “ALL”);
date = dateformat(RssQry.Rss_posted_date[ctr], “ddd, dd mmm yyyy”);
time = timeformat(RssQry.Rss_posted_date[ctr], “HH:mm:ss”) & ” EST”;
author = replace(RssQry.Rss_author[ctr], “<”, “<”, “ALL”);
author_email = replace(RssQry.Rss_author_email[ctr], “at>”, “@”, “ALL”);
author_email = replace(author_email, “<”, “<”, “ALL”);
</cfscript>
<cfoutput>
<item>
<title>#title#</title>
<description>#description#</description>
<link>http://tutorial#RssQry.Rss_id[ctr]#.easycfm.com</link>
<author>#author_email# (#author#)</author>
<pubDate>#date# #time#</pubDate>
</item>
</cfoutput>
</cfloop>
<cfoutput>
</channel>
</rss>
</cfoutput>
</cfsavecontent>