Quantcast
Channel: Pentaho Community Forums
Viewing all articles
Browse latest Browse all 16689

XML Input Stream (StAX)

$
0
0
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:



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>

Please note that the whole code is in a single line without line breaks:
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.
Attached Files

Viewing all articles
Browse latest Browse all 16689

Trending Articles