Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to process xml message with multiple loops ..

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

 

 

Labels (3)
6 Replies
Anonymous
Not applicable
Author

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

Anonymous
Not applicable
Author

Thanks for Reply.

Is there any possibility to do  in Enterprise edition

Anonymous
Not applicable
Author

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

0683p000009LtCb.png

And a second one to get the flat file:

0683p000009Lske.png

 

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

 

Anonymous
Not applicable
Author

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>

Anonymous
Not applicable
Author

You can handle it too. You will need three maps.

Anonymous
Not applicable
Author

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