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

Announcements
April 13–15 - Dare to Unleash a New Professional You at Qlik Connect 2026: Register Now!
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

How to loop through nested elements in tInputFileXML

Hi: I have an xml file that has nested child elements. All these child elements can have 1 and more occurrences. Can some one tell how to set the xpath loop expression for all these nested elements while creating the meta data.
Thanks,
RJ
Labels (3)
4 Replies
Anonymous
Not applicable

Hello RJ
Can you give us an example of you file and what are your expected result?
Best regards

shong
_AnonymousUser
Specialist III
Specialist III
Author

Hi: Shong, here is the trim down example. BTW In this example we have more than one occurrences of 2 elements named <oversight_info> and <primary_outcome> but just to let you know all the elements under root node <clinical_study> can have 0 to many occurrences, so during the job design phase we can not guess what elements can have more than 1 occurrences, and we want to get them all.
BTW one more thing not directly related to the this scenario, but a general question, what version (1.0 or 2.0) of XPATH Talend supports to extract the fields from File XML meta data wizard.
<?xml version="1.0" encoding="UTF-8"?>
<clinical_study rank="1">

<brief_title>Feasibility Study of Take-Home LAAM Medication - 3</brief_title>
<official_title>Feasibility Study of Take-Home LAAM Medication</official_title>
<source>National Institute on Drug Abuse (NIDA)</source>
<oversight_info>
<authority>United States: Federal Government</authority>
</oversight_info>
<oversight_info>
<authority>Germany: Federal Government</authority>
</oversight_info>
<primary_outcome>
<measure>Drug use</measure>
</primary_outcome>
<primary_outcome>
<measure>Retention</measure>
</primary_outcome>
<primary_outcome>
<measure>Increased prosocial behaviors</measure>
</primary_outcome>
<primary_outcome>
<measure>Decreased frequency of HIV related behavior</measure>
</primary_outcome>
<enrollment>0</enrollment>
<condition>Opioid-Related Disorders</condition>
<intervention>
<intervention_type>Drug</intervention_type>
<intervention_name>LAAM</intervention_name>
</intervention>
</clinical_study>
Anonymous
Not applicable

Hello
BTW one more thing not directly related to the this scenario, but a general question, what version (1.0 or 2.0) of XPATH Talend supports to extract the fields from File XML meta data wizard.

We use version 1.0 to parse xml file.
but just to let you know all the elements under root node <clinical_study> can have 0 to many occurrences

<clinical_study> must be at leat 1 occurrences, so I think you should wirte some java code to parse the xml file and check it contains <clinical_study>node at the begging of job, if so, do the next processing, otherwise, do nothing.
BTW In this example we have more than one occurrences of 2 elements named <oversight_info> and <primary_outcome> but just to let you know all the elements

Using two tFileInputXML to set different loop xpath, <oversight_info> and <primary_outcome>, eg:
"/clinical_study/oversight_info"
"/clinical_study/primary_outcome"
and then merge all the records if needed.
Best regards

shong
Anonymous
Not applicable

For detailed explanation of reading and processing XML file with multiple nested loops visit the blog post
http://vikramtakkar.blogspot.in/2013/02/read-xml-having-multiple-nested-loops.html