XML files compare and update

Highlighted
One Star

XML files compare and update

Hi,
I would like to compare to XML files and create a third XML file which is a "merge" of both files.
Is it possible with Talend?
First File is like:
<racine name="TEST01">
<node name="node1">
<propertie NAME="couleur">"01"</propertie>
<propertie NAME="couleur">"02"</propertie>
<propertie NAME="prix">"10"</propertie>
</node>
<node name="node2">
<propertie NAME="couleur">"01"</propertie>
<propertie NAME="couleur">"02"</propertie>
<propertie NAME="prix">"10"</propertie>
</node>
<node name="node3">
<propertie NAME="couleur">"01"</propertie>
<propertie NAME="couleur">"02"</propertie>
<propertie NAME="prix">"10"</propertie>
</node>
</racine>
Second one is like:
<!-- Created with Liquid XML Studio - FREE Community Edition 7.0.3.780 (http://www.liquid-technologies.com) -->
<racine name="TEST01">
<node name="node1">
<propertie NAME="couleur">"01"</propertie>
<propertie NAME="couleur">"03"</propertie>
<propertie NAME="prix">"10"</propertie>
</node>
<node name="node3">
<propertie NAME="couleur">"01"</propertie>
<propertie NAME="couleur">"02"</propertie>
<propertie NAME="couleur">"03"</propertie>
<propertie NAME="prix">"10"</propertie>
</node>
<node name="node4">
<propertie NAME="couleur">"01"</propertie>
<propertie NAME="couleur">"02"</propertie>
<propertie NAME="prix">"20"</propertie>
</node>
</racine>
Result must be like:
<racine name="TEST01">
<node name="node1">
<propertie NAME="couleur">"01"</propertie>
<propertie NAME="couleur">"02"</propertie>
<propertie NAME="prix">"10"</propertie>
</node>
<node name="node2">
<propertie NAME="couleur">"01"</propertie>
<propertie NAME="couleur">"02"</propertie>
<propertie NAME="prix">"10"</propertie>
</node>
<node name="node3">
<propertie NAME="couleur">"01"</propertie>
<propertie NAME="couleur">"02"</propertie>
<propertie NAME="couleur">"03"</propertie>
<propertie NAME="prix">"10"</propertie>
</node>
<node name="node4">
<propertie NAME="couleur">"01"</propertie>
<propertie NAME="couleur">"02"</propertie>
<propertie NAME="prix">"20"</propertie>
</node>
</racine>
Highlighted
Community Manager

Re: XML files compare and update

Hello guy
I see that the two input xml files have the same structure, so you use a tFileList to iterate the two xml file, then merge the rows on tUnite. Here is an example, please see screeshots.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Highlighted
One Star

Re: XML files compare and update

Thanks a lot Shong.
I got one more question.
Now, I would like to update the content of 2 elements if they exist in both files.
For instance, in file 1 I have:
<node name="node1">
<propertie NAME="couleur1">"01"</propertie>
<propertie NAME="couleur2">"02"</propertie>
<propertie NAME="couleur3">"03"</propertie>
<propertie NAME="prix">"10"</propertie>
</node>
In file 2, I have:
<node name="node1">
<propertie NAME="couleur1">"01"</propertie>
<propertie NAME="couleur2">"04"</propertie>
<propertie NAME="prix">"10"</propertie>
</node>
Result must be like:
<node name="node1">
<propertie NAME="couleur1">"01"</propertie>
<propertie NAME="couleur2">"04"</propertie>
<propertie NAME="couleur3">"03"</propertie>
<propertie NAME="prix">"10"</propertie>
</node>

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog