[resolved] tXMLMap loop through root and child nodes.
Hello, I have a problem regarding loops in tXMLMap. Since TXmlMap doesnt allow to have a loop on both root and child elements, I cant seem to figure out the way to complete my task. I need to send payload to tESBProviderResponse with same schema as a response from a web service. I marked the elements that should be looped through in the image, and also provided with a way my response should look like. LINK TO THE IMAGE: http://postimg.org/image/g7hjsv7gf/full/ Can anyone link me to a tutorial on that would solve this problem, or supply me with a solution? Thank you in advance, Algimantas
Solved this problem by simply using tMap instead of tXMLMap and just threw the payload i get from tESBConsumer straight to tESBResponse, thus skipping the mapping part where i had to deal with multiloops.
spiderman - if you've not solved your issue yet, I'm wondering if you've tried the tFileOutputMSXML component that allows for looping at parent and child nodes?
Solved this problem by simply using tMap instead of tXMLMap and just threw the payload i get from tESBConsumer straight to tESBResponse, thus skipping the mapping part where i had to deal with multiloops.
For future reference, the tExtractXMLField component is very useful when trying to extract data from XML with nested loops. But I guess as you simply want to pass from the input to output, you do not need to extract the data and rebuild it 🙂 Suviga, he didn't extract any data. He simply passed the data as a Document through the tMap. If you want to extract data from nested loops, then look at the tExtractXMLField component. You will also need to look at XPath queries to get the best use out of this.
rhel, I think my scenario is completely different.
<root>
<items>
</item>
</item>
</items>
<places>
</place>
</place>
</places>
</root>
I am able to set loop in both item and place (since they are in same level) using tXMLMap
But if I want one more loop at a city node(which is a child of place)
<root>
<items>
</item>
</item>
</items>
<places>
<place>
<cities>
</city>
</city>
</cities>
</place>
<place>
<cities>
</city>
</city>
</cities>
</place>
</places>
</root>
I am not able to achieve this as loops can't be set both at parent and child level.
Note: Link to references if any will be helpful as I am very new to Talend
Take a look at the tExtractXMLField component. You can use these components in combination to extract multiple loops (nested as well), but it takes a little work. I don't have any links to demonstrate this I am afraid. But your question has got me thinking about a good tutorial to write 🙂 Consider extracting the elements containing looped data as "nodes" using the tExtractXMLField component. Then pass those nodes to subsequent tExtractXMLField components to extract the detail data from those nodes. Take a look at the Talend documentation on the component to see how this is done.
I will put together a tutorial on this and when it is online I will share the link.