Question

I'm working with Mule Community Edition and I'm trying to convert an inbound XML file into CSV format. The inbound file is in the following format:

<field1></field1>
<field2></field2>
...
<field3>
  <field3a>
    <subfield3a1></subfield3a1>
    ...
  </field3a>
  <field3b>
    <subfield3b1></subfield3b1>
    ...
  </field3b>
</field3>

The complexity comes in the requirement for the output of this input file. I need to output the content of the XML file in CSV format, with one row containing fields 1,2 and then for field 3, I need one row for the content of field 3a, then one for 3b so something in the following format:

Line 1 of CSV: Field1, Field2...
Line 2 of CSV: Subfield3a1, Subfield 3a2...
Line 3 of CSV: Subfield3b2, Subfield 3b2...

Hope my issue here is clear. Unfortunately I am working with the CE of Mule so if any suggestions as to how to approach this could bear that in mind, that would be great. Thanks in advance.

Was it helpful?

Solution

You should be able to do that with XSL-T (text output) or a Groovy transformer (XML slurper).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top