Listing 1: roster.cfc

<cfcomponent>
<cffunction name="getPlayers" access="public" returntype="string" output="false">
<cfset var plrQry = queryNew("")/>
<cfset var retXML = ""/>
<cfquery dataSource="myDataSource" name="plrQry">
SELECT name, position FROM players
</cfquery>
<cfsavecontent variable="retXML">
<cfoutput>
<firstXI>
   <cfloop query="plrQry">
   <player>
   <name>#name#</name>
   <position>#position#</position>
   </player>
   </cfloop>
   </firstXI>
  </cfoutput>
  </cfsavecontent> <cfreturn retXML/>
  </cffunction>
</cfcomponent>

Listing 2: playersXML.

cfm<cfset roster = createObject('component', 'cfc.roster')/>
<cfcontent type="text/xml" reset="true">
<cfoutput>#roster.getPlayers()#
</cfoutput>
</cfcontent>