Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
How can i process and xml with nested loops.below is my xml and expected output.I can split each loop and join using tmap but is there any other solution for this,i am using Talend open studio fro big data.
Any help would be appreciated.
<flighttic>
<tic_id>565662</tic_id>
<Booked_ticket_date>03-03-2018 12:45:66</Booked_ticket_date>
<person_details>
<person>
<fname>jakka</fname>
<lname>dilip</lname>
<flyinf0>
<fly>
<supplier>ETHIAD</supplier>
</fly>
</flyinf0>
<Meals>
<preference>
<mealcode>chi</mealcode>
<mealno>2</mealno>
</preference>
<preference>
<mealcode>CHI</mealcode>
<mealno>5</mealno>
</preference>
</Meals>
<sittinginfo>
<siiting>
<number>1</number>
<seatloc>6A</seatloc>
</siiting>
<siiting>
<number>2</number>
<seatloc>9B</seatloc>
</siiting>
</sittinginfo>
</person>
</person_details>
</flighttic>
| tic_id | Booked_ticket_date | fname | lname | supplier | mealcode | mealno | number | seatloc |
| 565662 | 03-03-2018 12:45:66 | jakka | dilip | ETHIAD | CHI | 2 | 1 | 6A |
| 565662 | 03-03-2018 12:45:66 | jakka | dilip | ETHIAD | CHI | 5 | 2 | 9B |
| 565662 | 03-03-2018 12:45:66 | jakka | dilip | ETHIAD | CHI | 5 | 1 | 6A |
| 565662 | 03-03-2018 12:45:66 | jakka | dilip | ETHIAD | CHI | 2 | 2 | 9B |
Hi ss1417
It is impossible to read multiple loop element and join the data on one component, as you did, need to read each loop element and join the data back on a tMap.
Regards
Shong
Thanks for Reply.
Is there any possibility to do in Enterprise edition
Hi,
You can do that in data mapper.
You will need two maps:
1- A first one to get as many line as meal and get nested loop with sitting informations
And a second one to get the flat file:
You will get:
565662,03-03-2018 12:45:66,jakka,dilip,ETHIAD,chi,2,1,6A
565662,03-03-2018 12:45:66,jakka,dilip,ETHIAD,chi,2,2,9B
565662,03-03-2018 12:45:66,jakka,dilip,ETHIAD,CHI,5,1,6A
565662,03-03-2018 12:45:66,jakka,dilip,ETHIAD,CHI,5,2,9B
Regards.
Eric
Thanks eric but what will will the case if xml has multiple fly info as below even there it works the same package logic
<flighttic>
<tic_id>565662</tic_id>
<Booked_ticket_date>03-03-2018 12:45:66</Booked_ticket_date>
<person_details>
<person>
<fname>jakka</fname>
<lname>dilip</lname>
<flyinf0>
<fly>
<supplier>ETHIAD</supplier>
</fly>
<fly>
<supplier>quatar</supplier>
</fly>
<fly>
<supplier>singapore</supplier>
</fly>
</flyinf0>
<Meals>
<preference>
<mealcode>chi</mealcode>
<mealno>2</mealno>
</preference>
<preference>
<mealcode>CHI</mealcode>
<mealno>5</mealno>
</preference>
</Meals>
<sittinginfo>
<siiting>
<number>1</number>
<seatloc>6A</seatloc>
</siiting>
<siiting>
<number>2</number>
<seatloc>9B</seatloc>
</siiting>
</sittinginfo>
</person>
</person_details>
</flighttic>
You can handle it too. You will need three maps.
Thanks eric.i have another use case as below
i have xml in below format and i needed output as below,how can i do this,is there any possibility in Talend open studio.
<flighttic>
<pid>54846515522</pid>
<amount>2511</amount>
<person_details>
<person>
<fname>jakka</fname>
<lname>dilip</lname>
<flyinf0>
<fly>
<supplier>ETHIAD</supplier>
<date>2017/3/20 11:45 </date>
<mealcode>25</mealcode>
</fly>
<fly>
<supplier>American airlines</supplier>
<date>2017/3/21 22:45 </date>
<mealcode>19</mealcode>
</fly>
<fly>
<supplier>southwest</supplier>
<date>2017/3/23 14:45 </date>
</mealcode>
</fly>
<fly>
<supplier>southwest</supplier>
<date>2017/3/23 18:30</date>
<mealcode>25</mealcode>
</fly>
</flyinfo>
</person>
</person_details>
</flighttic>
| pid | amount | fname | lanme | supplier | date | mealcode |
| 5.48E+10 | 2511 | jakka | dilip | ETHIAD|American airlines|southwest|southwest | 2017/3/20 11:45|2017/3/21 22:45|2017/3/23 14:45|2017/3/23 18:30 | 25|19||25
|