Producing XML with nested elements

One Star

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
One Star

Re: Producing XML with nested elements

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
One Star

Re: Producing XML with nested elements

So I produce a file, then the second job reads the file and adds to it?
Thanks
One Star

Re: Producing XML with nested elements

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.
One Star

Re: Producing XML with nested elements

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.

Re: Producing XML with nested elements

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
One Star

Re: Producing XML with nested elements

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?
One Star

Re: Producing XML with nested elements

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