Skip to main content
Known Participant
August 19, 2009
Answered

can we loop xml with dynamic values...

  • August 19, 2009
  • 1 reply
  • 649 views

This is  what I am trying

<cfloop index="i" from="1" to="13" step="1">
<cfxml variable="data">
<records>
<record>
<Number>#i#</Number>
<SKU>#Form["sku_" & i]#</SKU>
<Quality>#Form["qty_"  & i]#</Quality>
<Description>#Form["product_" & i]#</Description>
</record>
</records>
</cfxml>
<cfset XMLText=ToString(data)>
<cffile action="APPEND" file="#ExpandPath('order.xml')#" output="#XMLText#">
</cfloop>

I can see only last varables upload into xml not all 13 its only 13...

    This topic has been closed for replies.
    Correct answer ilssac

    I would try this:

    <cfxml variable="data">
    <records>
    <cfloop index="i" from="1" to="13" step="1"><record>
    <Number>#i#</Number>
    <SKU>#Form["sku_" & i]#</SKU>
    <Quality>#Form["qty_"  & i]#</Quality>
    <Description>#Form["product_" & i]#</Description>
    </record>

    </cfloop>
    </records>
    </cfxml>
    <cfset XMLText=ToString(data)>
    <cffile action="WRITE" file="#ExpandPath('order.xml')#" output="#XMLText#">

    1 reply

    ilssac
    ilssacCorrect answer
    Inspiring
    August 19, 2009

    I would try this:

    <cfxml variable="data">
    <records>
    <cfloop index="i" from="1" to="13" step="1"><record>
    <Number>#i#</Number>
    <SKU>#Form["sku_" & i]#</SKU>
    <Quality>#Form["qty_"  & i]#</Quality>
    <Description>#Form["product_" & i]#</Description>
    </record>

    </cfloop>
    </records>
    </cfxml>
    <cfset XMLText=ToString(data)>
    <cffile action="WRITE" file="#ExpandPath('order.xml')#" output="#XMLText#">