XML files compare and update

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

Cloud Free Trial

Try Talend Cloud free for 30 days.

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.