Home > Blockchain >  PDI Pentaho - Building nested XML file
PDI Pentaho - Building nested XML file

Time:01-27

I want to build an XML file from a CSV file.

The CSV file has a structure of this kind for each row:

Const1
D1 (Discriminant 1)
V1
V2
.
.
.
Vn

The XML should have this structure:

<?xml....>
<Tag1>
    <Tag2>
        <Const1\>
        <D1\>
    <\Tag2>
    <BigTag1>
        <V1\>
        <Under-Tag1>
            <v1.1\>
        <\Under-Tag1>
        <Under-Tag2>
            <v1.2\>
        <\Under-Tag2>
    <\BigTag1>
<\Tag1>

I achieved the construction of the outer structure (heading, Tag1, Tag2) working with strings and concatenation (heading Tag1 Tag2 Closing Tag1). I have problems with the nested xml, how would I achieve in Pentaho PDI the nesting of Under-Tagn inside BigTagn?

I want to at least create a different xml file for each row of csv (i.e. a file for each Tag1).

CodePudding user response:

I got it; I used a Add Column XML step, created the <Under-Tag1>, called for example UT1, then the next step of the PDI is the construction of <BigTag1>, where I added as a field UT1, as String. In the next step I used Replace in String and substituted &lt; with <, &gt; with >.

PDI steps:

PDI

Step Add Column XML BigTag1:

AddXMLBT1

Char substitution:

enter image description here

  •  Tags:  
  • Related