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
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
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.
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.
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?