I want to merge 2 XML files using XSLT when there is matching 'id' attribute.
myFile1.xml (This is the first input file)
<?xml version="1.0" encoding="ISO-8859-1"?>
<test>
<node>
<type id="a">
<name>joe</name>
<name>kill</name>
</type>
</node>
<node>
<type id="b">
<name>sam</name>
</type>
</node>
</test>
myFile2.xml (This is the second input file)
<?xml version="1.0" encoding="ISO-8859-1"?>
<test>
<node>
<type id="a">
<name>jill</name>
<name>kill</name>
</type>
</node>
</test>
mergeOutput.xml (This is expected output where id is matched and 2 files are merged)
<?xml version="1.0" encoding="ISO-8859-1"?>
<test>
<node>
<type id="a">
<name>joe</name>
<name>jill</name>
<name>Kill</name>
</type>
</node>
<node>
<type id="b">
<name>sam</name>
</type>
</node>
</test>
Any XSLT code or link to the code would be helpful. I am not having XSLT knowledge and using this merge to get things working.
The output of this transform is (See kill is duplicated) -
You can do this in
LINQ2XML
XSLT 2.0 solution: