Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Producing XML with nested elements

How would I go about producing an XML file that has nested elements?
In talend 4.2.4 I believe you can only have one loop element, so how do I iterate to produce multiple instances of sub elements.
In my case, the data is coming from a normalised database.
Thanks
Labels (3)
7 Replies
Anonymous
Not applicable
Author

Hi
Yes. In Talend you can only have one loop element for each time.
For example, I have two loop elements in one xml file. One is rootA. The other is rootB.
You might create two subjobs for these two loop elements seperately.
Regards,
Pedro
Anonymous
Not applicable
Author

So I produce a file, then the second job reads the file and adds to it?
Thanks
janhess
Creator II
Creator II

Use tAdvancedFileOutputXML for output. Have an input for the main section and a separate input for each loop and connect to the tAdvancedFileOutputXML
The input's for the loop must have a field to reference the main section key element.
Anonymous
Not applicable
Author

Sorry I'm still not clear on this. My elements are nested, so it's not that I have more than one root element, I have to iterate within an iteration e.g.
<CATALOGUE>
<PRODUCT>A<SKU>1</SKU><SKU>2</SKU></PRODUCT>
<PRODUCT>A<SKU>1</SKU><SKU>2</SKU></PRODUCT>
</CATALOGUE>
So in the above example, one input drives <PRODUCT> and another iteration within that is required to produce the <SKU> elements. However, because they share the same root, and each input can only have one loop element, it doesn't seem possible.
The closest I've got to that is using tFileOutputMSXML, but it doesn't reliably put the elements within the same structure as it seems designed for multiple root elements, not nested loops.
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

Vikram,
Your blog shows how to read an xml file with multiple nested loops, but it's not clear how to create that kind of XML.
How do you go about producing that XML file in Talend from a one-to-many database?
Swell
Contributor
Contributor

I think this blog post may have what you are looking for.
http://bekwam.blogspot.com/2011/09/xml-output-from-multiple-data-sources.html