Read XML having Multiple Nested Loops in Different Parent Node

Four Stars

Read XML having Multiple Nested Loops in Different Parent Node

We need to process a xml with data such that it has multiple values in two child nodes.
When i loop it on DesignatedCountryCode it doesnot read multiple ClassNumber values and when i loop it on ClassNumber it doesnot read data for multiple DesignatedCountryCode. 
 Below is the sample data:
<TradeMark>
 <TradeMarkIdentifier>273985233</TradeMarkIdentifier>
 <DesignatedCountryDetails>
   <DesignatedCountry>
  <DesignatedCountryCode>SG</DesignatedCountryCode>
  <DesignatedUnderCode>Protocol</DesignatedUnderCode>
   </DesignatedCountry>
    <DesignatedCountry>
<DesignatedCountryCode>AM</DesignatedCountryCode>
<DesignatedUnderCode>Protocol</DesignatedUnderCode>
   </DesignatedCountry>
 </DesignatedCountryDetails>
 <GoodsServicesDetails>
   <GoodsServices>
<ClassificationKindCode>Nice</ClassificationKindCode>
<ClassDescriptionDetails>
  <ClassDescription>
    <ClassNumber>35</ClassNumber>
    <GoodsServicesDescription languageCode="en" hashKey="GOMLWgjSHm95KAe3qGkqcILQ4Zo=">Advertising; business management; business administration; </GoodsServicesDescription>
  </ClassDescription>
  <ClassDescription>
    <ClassNumber>36</ClassNumber>
    <GoodsServicesDescription languageCode="en" hashKey="eBoBcVWuav1yLPZk3Q78xPsnR/k=">Financial affairs; real estate affairs; .</GoodsServicesDescription>
  </ClassDescription>
</ClassDescriptionDetails>
   </GoodsServices>
 </GoodsServicesDetails>
</TradeMark>
Please help.
Thanks,
Saurabh.
Six Stars

Re: Read XML having Multiple Nested Loops in Different Parent Node

Hi Shukla,
If you are using Talend Enterprise Edition version more than 5.4.1. You will have Talend Data Mapper, which is capable of processing complex xml files. 
If you are using open studio or older version of Talend then we will not have TDM.  Even though older versions have tfileinputxml component, this can n't help for complex xml files.
Thanks,
L Raghunath.
Raghunath Lingutla
Five Stars

Re: Read XML having Multiple Nested Loops in Different Parent Node

you can do it using following job design.
tFileInputXMl---tXMLMap---(out one for first loop)
                          \(output two for second loop segment)
Now follow the instructions from read xml with nested loops.
Four Stars

Re: Read XML having Multiple Nested Loops in Different Parent Node

Hi Umesh,
Thanks for the reply , i am doing this on Talend sandbox and did what you suggested. But problem with above solution is that ultimately i want to make a list of the multiple element and load it as one row for every id. If i divide it in multiple outputs i am not able to join the two flows after aggregating. My flow looks like this:
                                      --> taggregator1 --> tlogrow1
txmlinput --> txmlmap --> 
                                     --> taggregator2 -->tlogrow2
I want to join the data of flow1 and flow2 and load it into cassandra.
Please suggest.
Thanks,
Saurabh.
Five Stars

Re: Read XML having Multiple Nested Loops in Different Parent Node

for that you need to store your data either in file/db or tHashXXXXX components and then read it again for merge it. 
after tAggregate ---tFileoutput. do it for both the flow. 

use tFileinput with same schema which was used in last tFileOutput component. 
use merge or tMap/tJon to make it one row. 
tFileinput-----tMap-----main---youroutput. 
tFileinput -----/
Create temporary id using numeric.sequence and share same id with both the flow then use this column for joining.
Four Stars

Re: Read XML having Multiple Nested Loops in Different Parent Node

Yes but this seems a complex solution in case of 70-75 multi value fields.I will need to write it in 75 temp files and process it in next flow. This inturn will have performance impact as well.. !!
Thanks a lot for suggesting this and replying on my post!!
-Saurabh.