Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello
I have simple job to do, maybe it's very simple, but I am not able to get it.
I want to transform a csv file into xml.
tflieInputdelimited -> tmap -> tadvancedfileoutputxml.
My csv is:
sku:warehouse;qty
a;ny;2
b;ca;3
c;la;1
I am having this output:
<body>
<products>
<product>
<sku>a</sku>
<warehouse>ny</warehouse>
<qty>2</qty>
</product>
<product>
<sku>b</sku>
<warehouse>ca</warehouse>
<qty>3</qty>
</product>
<product>
<sku>c</sku>
<warehouse>la</warehouse>
<qty>1</qty>
</product>
</products>
</body>
But I want this output
<body>
<products>
<product>
<sku>a</sku>
<warehouse>ny</warehouse>
<qty>2</qty>
<sku>b</sku>
<warehouse>ca</warehouse>
<qty>3</qty>
<sku>c</sku>
<warehouse>la</warehouse>
<qty>1</qty>
</product>
</products>
</body>
Is this possbile?
Hello @Ruben Silva ,
It's impossible to do that by using tAdvancedFileOutputXML component.
To achieve your goal, it need to do additional steps to read the xml root content as string then replace "</product>
<product>" as empty like the below
output_row.xml= input_row.xml.replaceAll("<\\/product>\\s+<product>","");
Thank you for you answer.
In the meantime, the team is asking for a json file with an array of details like this:
[
{
"sku" : "A",
"warehouse" : "NY",
"qty" : 2
},
{
"sku" : "B",
"warehouse" : "CA",
"qty" : 3
},
{
"sku" : "C",
"warehouse" : "LA",
"qty" : 1
}
]
I never worked with json files before, can you show me steps?
Thank you!