XML magic / repeating sections
Posted: Wed Sep 22, 2021 4:57 pm
We want to generate some XML on the fly for an order type that we get. We can setup a template and use XML magic to populate the majority of this OK.
The problem we have is that the number of "Order Lines" in the XML will be variable. So, there may be one product ordered, or many products.
Below is an example of an XML structure we would have. The "ItemOut" section would need to repeated on the fly depending on how many we need for that specific order. And then we'd need to update the elements in each one (price/quantity etc).
<Request>
<OrderRequest>
There are lots of nodes in this section relating to the order which we can update.
<ItemOut lineNumber="1" quantity="125">
<ItemDetail>
<Description>Product details</Description>
<Price>£10</Price>
</ItemDetail>
</ItemOut>
<ItemOut lineNumber="2" quantity="250">
<ItemDetail>
<Description>Another products details</Description>
<Price>£15</Price>
</ItemDetail>
</ItemOut>
</OrderRequest>
</Request>
Can we use XML magic to do this or would we need a further plugin like Variable XPath Repeater?
Thanks,
Matt
The problem we have is that the number of "Order Lines" in the XML will be variable. So, there may be one product ordered, or many products.
Below is an example of an XML structure we would have. The "ItemOut" section would need to repeated on the fly depending on how many we need for that specific order. And then we'd need to update the elements in each one (price/quantity etc).
<Request>
<OrderRequest>
There are lots of nodes in this section relating to the order which we can update.
<ItemOut lineNumber="1" quantity="125">
<ItemDetail>
<Description>Product details</Description>
<Price>£10</Price>
</ItemDetail>
</ItemOut>
<ItemOut lineNumber="2" quantity="250">
<ItemDetail>
<Description>Another products details</Description>
<Price>£15</Price>
</ItemDetail>
</ItemOut>
</OrderRequest>
</Request>
Can we use XML magic to do this or would we need a further plugin like Variable XPath Repeater?
Thanks,
Matt