I have the following xml as my input
InputXML:
<Orders>
<Order>
<sample id="1"></sample>
<sample id="2"></sample>
.
.
.
.
</Order>
<Order>
<sample id="1"></sample>
<sample id="2"></sample>
.
.
.
.
</Order>
<Order>
<sample id="1"></sample>
<sample id="2"></sample>
.
.
.
.
</Order>
.
.
.
.
</Orders>
I need to send this xml to the batch component in my flow. My batch should accept each record in the following manner
Record1:1st Order
Record2:2nd Order
Record3:3rd Order
.
.
.
.
Now please let me know what coding do I need to do in my DataWeave(Transform message) component to acheive this scenario.I tried multiple ways but no result. I am trying this from past few days and got tired. Please help me in this regard!! Please share the sample code.
Output should look like:
1) Order ---- Object
sample-----Object
-sampleValue(i.e; value of 'sample' element)
-sampleidValue(i.e; value of attribute of 'sample')
sample-----Object
-sampleValue(i.e; value of 'sample' element)
-sampleidValue(i.e; value of attribute of 'sample')
.
.
.
.
2) Order ---- Object
sample-----Object
-sampleValue(i.e; value of 'sample' element)
-sampleidValue(i.e; value of attribute of 'sample')
sample-----Object
-sampleValue(i.e; value of 'sample' element)
-sampleidValue(i.e; value of attribute of 'sample')
.
.
.
.
Inside Batch:
I do have another dataweave component that transforms this collection to csv.
The input of this dataweave component is each object from this collection. The data is extracted from this object and written to the CSV file.
Updated Question:
The issue I am facing is Each Object in the collection is of structure
Order ---- Object
sample1-----Object
-sampleValue(i.e; value of 'sample' element)
-sampleidValue(i.e; value of attribute of 'sample')
sample2-----Object
-sampleValue(i.e; value of 'sample' element)
-sampleidValue(i.e; value of attribute of 'sample')
.
.
.
.
But the output of my CSV should be:
sample1.sampleValue sample3.sampleValue . . . .(this is 'Order1' object)
sample2.sampleValue sample6.sampleValue . . . .(this is 'Order2' object)
.
.
.
.
I am not able to get the output this way in the CSV file. bcz my 'sample' is also a List of Objects. I tried this in both DataMapper and DataWeave also. Please help me out how to extract the values.