Hello,
I need to transform an xml file and output it to a csv-file using the Input Stream (StAX) step.
The XML structure looks like this:
Please note that the whole code is in a single line without line breaks:
the expected output should look like this:
Any help on this challenge would be greatly appreciated as I am a beginner at this.
I need to transform an xml file and output it to a csv-file using the Input Stream (StAX) step.
The XML structure looks like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<cpstruct maxid="395">
<ts>
<t tn="3bf39e70-a81d-4dd0-a903-c6354778eeb4" tmk="2">
<tis>
<ti txi="0" tv="Value1" active="True" />
<ti txi="1" tv="Value2" active="True" />
<ti txi="2" tv="Value3" active="True" />
</tis>
</t>
</ts>
<pds>
<pd px="238" pdn="QUESTION1" pxi="st" />
<pd px="240" pdn="QUESTION2" pxi="st" />
<pd px="242" pdn="QUESTION3" pxi="st" />
<pd px="377" pdn="List" pxi="3bf39e70-a81d-4dd0-a903-c6354778eeb4" />
</pds>
</cpstruct>
Code:
<?xml version="1.0" encoding="UTF-8"?><cpstruct maxid="395"> <ts> <t tn="3bf39e70-a81d-4dd0-a903-c6354778eeb4" tmk="2"> <tis> <ti txi="0" tv="Value1" active="True" /> <ti txi="1" tv="Value2" active="True" /> <ti txi="2" tv="Value3" active="True" /></tis></t></ts><pds> <pd px="238" pdn="QUESTION1" pxi="st" /> <pd px="240" pdn="QUESTION2" pxi="st" /> <pd px="242" pdn="QUESTION3" pxi="st" /> <pd px="377" pdn="List" pxi="3bf39e70-a81d-4dd0-a903-c6354778eeb4" /> </pds></cpstruct>
the expected output should look like this:
px | pdn | txi | tv | active |
-------- | ---------------------- | ---- | ----- | ------- |
238 | QUESTION1 | |||
240 | QUESTION2 | |||
242 | QUESTION3 | |||
377 | List | 0 | Value1 | TRUE |
377 | List | 1 | Value2 | TRUE |
377 | List | 2 | Value2 | TRUE |
Any help on this challenge would be greatly appreciated as I am a beginner at this.