I'm sure this is something i'm just missing because it's late in the day
but...
i have a simple CFC which is creating some xml files for me. if i have the
following code inside my function
<cfset var allNutrients = getNutrient()>
<cfset var returnThis = "">
<cfxml variable="xmloutput" casesensitive="yes">
<nutrients>
<cfloop query="allNutrients">
<nutrient name="#allNutrients.nutrientName#"
required="#allNutrients.required#" unit="numeric"
id="#allNutrients.nutrientid#" rdaUnit="#allNutrients.weightUnit#"
rda="#allNutrients.rdi#" ordinal="#allNutrients.ordinal#">
</cfloop>
</nutrients>
</cfxml>
and then run the function i get the error:
Document root element is missing. Document root element is missing. The
error occurred in *D:\usr\dpFoodMenu\www\components\menuXML.cfc: line 130*
128 : <cfloop query="allNutrients">
129 : <nutrient name="#allNutrients.nutrientName#"
required="#allNutrients.required#" unit="numeric"
id="#allNutrients.nutrientid#" rdaUnit="#allNutrients.weightUnit#"
rda="#allNutrients.rdi#" ordinal="#allNutrients.ordinal#">*130 :
</cfloop>*
131 : </nutrients>
132 : </cfxml>
BUT if i run this code:
<cfset var allNutrients = getNutrient()>
<cfset var xmloutput = XMLNew('yes')>
<cfset var returnThis = "">
<cfscript>
xmloutput.xmlRoot = XmlElemNew(xmloutput, "nutrients");
</cfscript>
<cfloop query="allNutrients">
<cfscript>
// Below script is based on this XMLoutput
//<nutrient name="#allNutrients.nutrientName#"
required="#allNutrients.required#" id="#allNutrients.nutrientid#"
rdaUnit="#allNutrients.weightUnit#" rda="#allNutrients.rdi#"
ordinal="#allNutrients.ordinal#" />
xmloutput.xmlroot.xmlChildren[allNutrients.currentRow] =
XmlElemNew(xmloutput, "nutrient");
xmloutput.xmlroot.xmlChildren[allNutrients.currentRow].xmlAttributes.name =
"#allNutrients.nutrientName#";
xmloutput.xmlroot.xmlChildren[allNutrients.currentRow].xmlAttributes.required
= "#allNutrients.required#";
xmloutput.xmlroot.xmlChildren[allNutrients.currentRow].xmlAttributes.id =
"#allNutrients.nutrientid#";
xmloutput.xmlroot.xmlChildren[allNutrients.currentRow].xmlAttributes.rdaUnit
= "#allNutrients.weightUnit#";
xmloutput.xmlroot.xmlChildren[allNutrients.currentRow].xmlAttributes.rda =
"#allNutrients.rdi#";
xmloutput.xmlroot.xmlChildren[allNutrients.currentRow].xmlAttributes.ordinal
= "#allNutrients.ordinal#";
</cfscript>
</cfloop>
It returns a good XML object... any ideas??
jonese
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:206808
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54