I am creating XML in ColdFusion to send data to QuickBooks. I can build my variable with my data from <cfoutput>fine. Like this:
<cfoutput query="get">
<cfset #x# =
'
<InvoiceAddRq>
<InvoiceAdd>
<CustomerRef>
<ListID>XXXXX</ListID>
</CustomerRef>
<ClassRef>
<ListID>XXXXX</ListID>
</ClassRef>
<TxnDate>2010-11-04</TxnDate>
<InvoiceLineAdd>
<ItemRef>
<ListID>XXXXX</ListID>
</ItemRef>
<Desc>XXXXX</Desc>
<Quantity>XXXXX</Quantity>
<Rate>XXXXX</Rate>
</InvoiceLineAdd>
</InvoiceAdd>
</InvoiceAddRq>
'
>
But I need to create XML where I view position data using <cfloop>internally <cfset>. This is what I am trying to do:
<cfoutput query="get">
<cfset
'
<InvoiceAddRq>
<InvoiceAdd>
<CustomerRef>
<ListID>XXXXX</ListID>
</CustomerRef>
<ClassRef>
<ListID>XXXXX</ListID>
</ClassRef>
<TxnDate>2010-11-04</TxnDate>
<cfquery name="getDetails">
</cfquery>
<cfloop query="getDetails">
<InvoiceLineAdd>
<ItemRef>
<ListID>XXXXX</ListID>
</ItemRef>
<Desc>XXXXX</Desc>
<Quantity>XXXXX</Quantity>
<Rate>XXXXX</Rate>
</InvoiceLineAdd>
</cfloop>
</InvoiceAdd>
</InvoiceAddRq>
'
>
This obviously does not work correctly, because it sees the attributes and as XML. I am trying to figure out how to write some XML, then execute my query and loop to get the position detail, and then return to XML. I don’t understand how to do this. I hope this makes sense and any help would be greatly appreciated.
source
share