0

我需要在 cfset 标记中使用 cfoutput 来获取要在 xml 中发送的多个行项目。我知道将 CF 标签放入另一个标签是错误的,但我正在寻找最好的方法来做到这一点。提前致谢。

<cfset soapBody = soapBody & "
    <cfoutput query="getitems">                        
    <item id=""#id#"">
        <unitPrice>#getitems.unitprice#</unitPrice>
        <quantity>#getitems.quantity#</quantity>
        <productname>#getitems.productname#</productname>
        <taxAmount>#getitems.taxamount#</taxAmount>
        <unitOfMeasure>#getitems.unitofmeasure#</unitOfMeasure>
        <taxRate>#getitems.taxrate#</taxRate>
        <totalAmount>#getitems.totalamount#</totalAmount>
        <grossNetIndicator>#getitems.grossnetindicator#</grossNetIndicator>
    </item>
    </cfoutput>         
">
4

1 回答 1

2

您可以<cfsavecontent>为此使用标签。在您尝试动态创建一大段字符串的情况下,它非常有用。

<cfsavecontent variable="soapBody">
    <cfoutput>#soapBody#</cfoutput>
    <cfoutput query="getitems">                        
    <item id=""#id#"">
        <unitPrice>#getitems.unitprice#</unitPrice>
        <quantity>#getitems.quantity#</quantity>
        <productname>#getitems.productname#</productname>
        <taxAmount>#getitems.taxamount#</taxAmount>
        <unitOfMeasure>#getitems.unitofmeasure#</unitOfMeasure>
        <taxRate>#getitems.taxrate#</taxRate>
        <totalAmount>#getitems.totalamount#</totalAmount>
        <grossNetIndicator>#getitems.grossnetindicator#</grossNetIndicator>
    </item>
    </cfoutput>         
</cfsavecontent>
于 2020-07-09T13:42:33.530 回答