One Star

[resolved] Convert XML to CVS using tFileInputXML

Hi, I have the following XML file that I need to output to CSV. The issue being that the A11_MV items are duplicated, but are correlative to the A15_MV items.
XML code:
<?xml version="1.0" encoding="UTF-8"?>
<ROOT
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CUSTOMER _ID = "2">
<A11_MV A11 = "C2000"/>
<A11_MV A11 = "M3000"/>
<A11_MV A11 = "S3000"/>
<A15_MV A15 = "8437"/>
<A15_MV A15 = "8437"/>
<A15_MV A15 = "8444"/>
</CUSTOMER>
<CUSTOMER _ID = "4">
<A11_MV A11 = "C3000"/>
<A15_MV A15 = "8439"/>
</CUSTOMER>
<CUSTOMER _ID = "6">
<A11_MV/>
<A15_MV/>
</CUSTOMER>
</ROOT>
The output I am looking for would be:
"2","C2000","8437"
"2","M3000","8437"
"2","S3000","8444"
"4","C3000","8439"
"6","",""
Any help would be greatly appreciated.
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] Convert XML to CVS using tFileInputXML

Hello
You can use two tFileInputXML components to extract data from the same file, one extract _ID and A11 node, another one extract _ID and A15 node, then do a inner jon and merge columns on tMap. see my screenshots.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
3 REPLIES
Community Manager

Re: [resolved] Convert XML to CVS using tFileInputXML

Hello
You can use two tFileInputXML components to extract data from the same file, one extract _ID and A11 node, another one extract _ID and A15 node, then do a inner jon and merge columns on tMap. see my screenshots.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Convert XML to CVS using tFileInputXML

Thanks shong.. Works a treat.
One Star

Re: [resolved] Convert XML to CVS using tFileInputXML

HI
When I am converting Xml to csv i am getting same output for the number of rows I have. My xml is
<?xml version="1.0" encoding="ISO-8859-15" ?>
- <root>
- <row>
<id>1</id>
<name>suresh</name>
</row>
- <row>
<id>2</id>
<name>naresh</name>
</row>
</root>
so there are two rows. So the output i am getting is
id;name
1;suresh
1;suresh
instead of
id;name
1;suresh
2;naresh
What is the solution to this? Please Help