Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
How to merge several XML files with different schemas but with a common sub-element which can be considered such as a key, "aid" into my example ?
Input files
XML File 1
----------
<?xml version="1.0" encoding="UTF-8"?>
<appointments>
<appointment>
<Field name="aid">27014</Field>
<Field name="XA_SB_CUSTOMER"/>
<Field name="XA_SECOND_DECODER_LOCATION"/>
...
<Field name="XA_WO_SIGNATURE_QUOTE_NAME_ACCPT"/>
<Field name="XA_ZUNNY_PARTNER_ID"/>
</appointment>
<appointment>
<Field name="aid">28071</Field>
<Field name="XA_SB_CUSTOMER"/>
<Field name="XA_SECOND_DECODER_LOCATION"/>
...
<Field name="XA_WO_SIGNATURE_QUOTE_NAME_ACCPT"/>
<Field name="XA_ZUNNY_PARTNER_ID"/>
</appointment>
<appointment>
<Field name="aid">28081</Field>
<Field name="XA_SB_CUSTOMER"/>
<Field name="XA_SECOND_DECODER_LOCATION"/>
...
<Field name="XA_WO_SIGNATURE_QUOTE_NAME_ACCPT"/>
<Field name="XA_ZUNNY_PARTNER_ID"/>
</appointment>
<appointment>
...
</appointment>
</appointments>
XML File 2
----------
<?xml version="1.0" encoding="UTF-8"?>
<appointments>
<appointment>
<Field name="aid">27014</Field>
<Field name="XA_TAP_BUILDING_LOCATION"/>
<Field name="XA_TAP_BUILDING_LOCATION_COMMENT"/>
...
<Field name="XA_SUSPEND_REASON"/>
<Field name="XA_SUSPEND_REASON_COMMENT"/>
</appointment>
<appointment>
<Field name="aid">28071</Field>
<Field name="XA_TAP_BUILDING_LOCATION"/>
<Field name="XA_TAP_BUILDING_LOCATION_COMMENT"/>
...
<Field name="XA_SUSPEND_REASON"/>
<Field name="XA_SUSPEND_REASON_COMMENT"/>
</appointment>
<appointment>
<Field name="aid">28081</Field>
<Field name="XA_TAP_BUILDING_LOCATION"/>
<Field name="XA_TAP_BUILDING_LOCATION_COMMENT"/>
...
<Field name="XA_SUSPEND_REASON"/>
<Field name="XA_SUSPEND_REASON_COMMENT"/>
</appointment>
<appointment>
...
</appointment>
</appointments>
XML File 3
----------
<?xml version="1.0" encoding="UTF-8"?>
<appointments>
<appointment>
<Field name="aid">27014</Field>
<Field name="XA_WIFI_COVERAGE_CHECKED"/>
<Field name="XA_WIFI_EXT_UC_MAT"/>
...
<Field name="XA_SUB_LOT_INIT"/>
<Field name="XA_SUB_LOT_END"/>
</appointment>
<appointment>
<Field name="aid">28071</Field>
<Field name="XA_WIFI_COVERAGE_CHECKED"/>
<Field name="XA_WIFI_EXT_UC_MAT"/>
...
<Field name="XA_SUB_LOT_INIT"/>
<Field name="XA_SUB_LOT_END"/>
</appointment>
<appointment>
<Field name="aid">28081</Field>
<Field name="XA_WIFI_COVERAGE_CHECKED"/>
<Field name="XA_WIFI_EXT_UC_MAT"/>
...
<Field name="XA_SUB_LOT_INIT"/>
<Field name="XA_SUB_LOT_END"/>
</appointment>
<appointment>
...
</appointment>
</appointments>
Expected Output XML File
<?xml version="1.0" encoding="UTF-8"?>
<appointments>
<appointment>
<Field name="aid">27014</Field>
<Field name="XA_WIFI_COVERAGE_CHECKED"/>
<Field name="XA_WIFI_EXT_UC_MAT"/>
<Field name="XA_TAP_BUILDING_LOCATION"/>
<Field name="XA_TAP_BUILDING_LOCATION_COMMENT"/>
<Field name="XA_SB_CUSTOMER"/>
<Field name="XA_SECOND_DECODER_LOCATION"/>
...
<Field name="XA_SUB_LOT_INIT"/>
<Field name="XA_SUB_LOT_END"/>
<Field name="XA_SUSPEND_REASON"/>
<Field name="XA_SUSPEND_REASON_COMMENT"/>
<Field name="XA_WO_SIGNATURE_QUOTE_NAME_ACCPT"/>
<Field name="XA_ZUNNY_PARTNER_ID"/>
</appointment>
<appointment>
<Field name="aid">28071</Field>
<Field name="XA_WIFI_COVERAGE_CHECKED"/>
<Field name="XA_WIFI_EXT_UC_MAT"/>
<Field name="XA_TAP_BUILDING_LOCATION"/>
<Field name="XA_TAP_BUILDING_LOCATION_COMMENT"/>
<Field name="XA_SB_CUSTOMER"/>
<Field name="XA_SECOND_DECODER_LOCATION"/>
...
<Field name="XA_SUB_LOT_INIT"/>
<Field name="XA_SUB_LOT_END"/>
<Field name="XA_SUSPEND_REASON"/>
<Field name="XA_SUSPEND_REASON_COMMENT"/>
<Field name="XA_WO_SIGNATURE_QUOTE_NAME_ACCPT"/>
<Field name="XA_ZUNNY_PARTNER_ID"/>
</appointment>
<appointment>
<Field name="aid">28081</Field>
<Field name="XA_WIFI_COVERAGE_CHECKED"/>
<Field name="XA_WIFI_EXT_UC_MAT"/>
<Field name="XA_TAP_BUILDING_LOCATION"/>
<Field name="XA_TAP_BUILDING_LOCATION_COMMENT"/>
<Field name="XA_SB_CUSTOMER"/>
<Field name="XA_SECOND_DECODER_LOCATION"/>
...
<Field name="XA_SUB_LOT_INIT"/>
<Field name="XA_SUB_LOT_END"/>
<Field name="XA_SUSPEND_REASON"/>
<Field name="XA_SUSPEND_REASON_COMMENT"/>
<Field name="XA_WO_SIGNATURE_QUOTE_NAME_ACCPT"/>
<Field name="XA_ZUNNY_PARTNER_ID"/>
</appointment>
<appointment>
...
</appointment>
</appointments>
Thanks.
@JC JC , I'm afraid there is no a Talend component that can merge the XML files. You can check whether it can be achieved through Java code.
Regards
Shong