One Star

[resolved] How to insert a xml node to an existing xml file

Hi there,
I am new to Talend.
I have a task to merge two xml file:
- Xml File #1
<root>
<row>
<column1>test</column1>
<column2>test</column2>
<column3>test</column3>
</row>
<row1>
<column1>test</column1>
<column2>test</column2>
<column3>test</column3>
</row1>
...
</root>

-XML File #2
<another_root>
<header></header>
<content>
<element1>
<subelement1></subelement1>
<subelement2></subelement2>
</element1>
<element2>
<subelement1></subelement1>
<subelement2></subelement2>
</element2>
...
</content>
</another_root>
so what I want to achieve is to grab "root" element from XML file #1 and insert it to underneath of element2.
In other words.....

<another_root>
<header></header>
<content>
<element1>
<subelement1></subelement1>
<subelement2></subelement2>
</element1>
<element2>
<subelement1></subelement1>
<subelement2></subelement2>
</element2>
... <--- root element of xml file #1 goes here
</content>
</another_root>

I researched all xml related components and could not figure out how to do this.
Please let me how it can be resolved. Thank you in advance.
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] How to insert a xml node to an existing xml file

Hi
You can try the 'append the source xml file' option on tAdvancedOutputXMLFile component, here is an simple example in topic: http://www.talendforge.org/forum/viewtopic.php?id=5975
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
2 REPLIES
Community Manager

Re: [resolved] How to insert a xml node to an existing xml file

Hi
You can try the 'append the source xml file' option on tAdvancedOutputXMLFile component, here is an simple example in topic: http://www.talendforge.org/forum/viewtopic.php?id=5975
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] How to insert a xml node to an existing xml file

Shong,
I appreciate your help. It worked like a charm.
Thanks,
Jong