Listing  1:

<CFQUERY name="getOrgs"  datasource="#variables.thedsn#" username=
  "#variables.thedsnusername#" password="#variables.thedsnpassword#">
SELECT distinct
organization
FROM Events
</CFQUERY>
<CFOUTPUT>
<CFSET NumberOfOrgs = getOrgs.RecordCount>
</CFOUTPUT>

<cfloop from="1" to = "#numberOfOrgs#" index="odx">

    <CFSET TheLPNORG = getOrgs.organization[odx]>
    <CFTRY>
    <cfquery name="getCount"  datasource="#variables.thedsn#"
	 username="#variables.thedsnusername#" password="#variables.
	 thedsnpassword#">
    SELECT *
    FROM Events
    WHERE eventdate >= #CreateODBCDATE(Now())#
    AND organization  = '#TheLPNORG#'
    </cfquery>
    <CFSET numberofFeedItems = getCount.RecordCount>
    <CFIF #variables.numberofFeedItems# gt 10>
        <cfset NumberOfFeedItems = 10>
    </CFIF>

    <CFIF #variables.NumberOfFeedItems# gt 0>
    <cfquery name="getContent"  datasource="#variables.thedsn#"
	 username="#variables.thedsnusername#" password="#variables.
	 thedsnpassword#">
    SELECT *
    FROM Events
    WHERE eventdate >= #CreateODBCDATE(Now())#
    AND organization  = '#TheLPNORG#'
    ORDER BY eventdate
    LIMIT #numberOfFeedItems#
    </cfquery>
    <cfset theDatetime = "#dateformat(now(),
    "ddd, dd mmm yyyy")# #timeformat(now(),
    "HH:mm:ss")# MST">

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

    <cfoutput><?xml version="1.0" encoding="ISO-8859-1" ?>
    <!--  RSS generated by LPN on #theDatetime# -->
    <rss version="2.0">
    <channel>
    <title>#TheLPNOrg# Events</title>
    <link>http://www.lapresenters.org</link>
    <description>Output of event calendar of the Louisiana
	 Presenters Network</description>
    <language>en-us</language>
    <copyright>Copyright Louisiana Presenters Network</copyright>
    <docs>http://www.lapresenters.org/rss</docs>
    <lastBuildDate>#theDatetime#</lastBuildDate>
    <image>
    <title>LPN</title>
    <url>http://www.lapresenters.org/images/LPNLogoTop2.gif</url>
    <link>http://www.lapresenters.org</link>
    </image>
    </cfoutput>

        <cfloop from="1" to = "#numberOfFeedItems#" index="ctr">
        <cfscript>
         title = replace(getContent.title[ctr],
        "&", "&", "ALL");
         EventType = replace(getContent.EventType[ctr],
        "<", "<", "ALL");
         EventCity = replace(getContent.EventCity[ctr],
        "<", "<", "ALL");
        title = REReplaceNoCase(title,"<[^>]*>-/","","ALL");
        date = dateformat(getContent.eventdate[ctr],
        "ddd, dd mmm yyyy");
        time = timeformat(getContent.eventdate[ctr],
        "HH:mm:ss") & " CDT";
        pubDate = date & " " & time;
        showdate = dateformat(getContent.eventdate[ctr],
         "ddd, mmm d, yyyy");
        showtime = getcontent.eventtime[ctr];
        </cfscript>
        <cfoutput>
       <item>
        <title>#XMLFORMAT(title)#</title>
        <description>#showdate# #XMLFormat(EventCity)#, LA #showtime#
		 #XMLFormat(EventType)#</description>

    <link>http://www.lapresenters.org/oneevent.cfm?event_id=#getContent.
	 event_id[ctr]#</link>
       <author>webmaster@lapresenters.org</author>
       <pubDate>#pubDate#</pubDate>
       </item>
        </cfoutput>
    </cfloop>
    <cfoutput>
    </channel>
    </rss>
    </cfoutput>
    </cfsavecontent>
    <cfscript>
    theLPNOrg = replace(#variables.thelpnorg#,
    " ", "", "ALL");
    theLPNOrg = replace(#variables.thelpnorg#,
    ".", "", "ALL");
    </CFSCRIPT>
    <cffile action="write" nameconflict="overwrite"
    file="c:\inetpub\lapresenters\rss\#THELPNORG#.xml" output="#theXml#">
    </CFIF>
    <CFCATCH>
    <CFOUTPUT>
    XML failure for #THELPNORG#<br>
    </CFOUTPUT>
    </CFCATCH>
    </CFTRY>

</cfloop>



Listing 2:

<CFTRY>
<CFQUERY datasource="#variables.thedsn#" username="#variables.
 thedsnusername#" password="#variables.thedsnpassword#">
DELETE FROM XMLEvents
WHERE XMLEVENT_ID > 0
</CFQUERY>

<CFQUERY name="getTheXMLs" datasource="#variables.thedsn#"
 username="#variables.thedsnusername#" password="#variables.
 thedsnpassword#">
SELECT member_id,organization,thexml
FROM members
WHERE thexml <> '' AND renewaldue > #variables.renewalthreshhold#
</CFQUERY>

<CFSET HowManyXMLs = getTheXMLs.RecordCount>



<cfloop from="1" to="#variables.HowManyXMLs#" index="xx">
<CFOUTPUT query="getTheXMLs" startrow="#xx#" maxrows="1">

<CFTRY>
<cfhttp url="#thexml#" method="get">
<cfset myDoc=XMLParse(CFHTTP.FileContent)>
<cfset Items=myDoc.rss.channel.XMLChildren>
<cfset myItemsArrayLength=ArrayLen(Items)-8>

    <cfloop from="1" to="#myItemsArrayLength#" index="idx">
    <CFSET theTitle = #myDoc.rss.channel.item[idx].Title.XMLText#>
    <CFSET theDescription = #myDoc.rss.channel.item[idx].Description.XMLText#>
    <CFSET theLink = #myDoc.rss.channel.item[idx].Link.XMLText#>

    <CFSET thepubDate = #ParseDateTime(myDoc.rss.channel.item[idx].
	 pubDate.XMLText)#>
    <CFSET theOrganization = #organization#>
    <CFQUERY name="addItems" datasource="#variables.thedsn#"
	 username="#variables.thedsnusername#" password="#variables.
	 thedsnpassword#">
    INSERT INTO XMLEvents (Title,Description,Link,pubDate,organization)
    VALUES

    ('#TheTitle#','#TheDescription#','#TheLink#',#ThePubDate#,'#
     TheOrganization#')
        </CFQUERY>
    </cfloop>
    #xx# #thexml#<br>
<br>


<CFCATCH>
<CFMAIL to="#variables.erroremail#"
from="#variables.erroremail#"
subject="XMLCAL within loop"
server="#variables.themailserver#"
type="HTML">

URL was: #thexml#<br>

Loop number #xx#<br>
<br>


Didn't load. A #cfcatch.type# exception occurred.
#cfcatch.message# #cfcatch.Detail#<br>
<br>

<CFDUMP var="#cfcatch.tagcontext#">

</CFMAIL>
Failure for URL: #thexml#<br>
Loop number: #xx#<br>
<br>
</CFCATCH>
</CFTRY>

</CFOUTPUT>
</cfloop>



<CFCATCH type="any">
<CFMAIL to="#variables.erroremail#"
from="#variables.erroremail#"
subject="CombineXML"
server="#variables.themailserver#"
type="HTML">
Didn't load. A #cfcatch.type# exception occurred.
#cfcatch.message# #cfcatch.Detail#<br><br>
<br>
This message occurs if any of the XML parse loops fails.
<br>

<CFDUMP var="#cfcatch.tagcontext#">

</CFMAIL>
Some sort of failure. Possibly a bad XML URL or site down when polled for XML.
</CFCATCH>

</CFTRY>