Duplicate:
I have two XML files which I'd like to merge.
The merged file should contain every element from both files (maintaining the hierarchy), when elements from the second XML can override elements from the first XML:
When two elements are identical (same XPATH, same properties), I'd like to override.
There are probably a million ways to do this - which is the most effortless (without learning XSLT, preferably)
Sample result:
File 1
<a>
<b foo="d"/>
<b bar="c"/>
<c/>
</a>
File 2
<a>
<b foo="e"/>
<b boo="c"/>
<c/>
</a>
<x>
<b bar="c"/>
</x>
Output
<a>
<b foo="d"/>
<b bar="c"/>
<b boo="c"/>
<c/>
</a>
<x>
<b bar="c"/>
</x>