When producing xml for AJAX projects, CFXML + CFOUTPUT is too slow.
Using ColdFusion's xmlelemnew and xmlnew function to create xml objects.
Using cfscript to write a ffunction and convert a query to a xml variable.
<cfscript>
function queryToXML(qry){
xmlobject=xmlnew();
xmlobject.xmlRoot =XmlElemNew(xmlobject,"info");
nodeAttributes=structnew();
structinsert(nodeAttributes,'recordcount',qry.recordcount);
xmlobject.xmlRoot.xmlattributes=nodeAttributes;
columnList=lcase(qry.columnlist);
for(i=1;i lte qry.recordcount;i=i+1){
xmlNode=XmlElemNew(xmlobject,"item");
nodeAttributes=structnew();
for(ii=1;ii ltelistlen(columnList,',');ii=ii+1){
columnName=listgetat(columnList,ii,',');
StructInsert(nodeAttributes,columnName,urldecode(qry[columnName][i],'utf-8'))
}
xmlNode.xmlattributes=nodeAttributes;
xmlobject.xmlRoot.xmlchildren[arraylen(xmlobject.xmlRoot.xmlchildren)+1]=xmlNode;
}
return xmlobject;
}
</cfscript>
+