I have two xml files, which need to be merged into one xml. Here is the example:
orginal.xml file :
<employees>
<employee id="1">
<name> Name1 </name>
<email> email1 <email>
</employee>
<employee id="2">
<name> Name2 </name>
<email> email2 <email>
</employee>
</employees>
update.xml file:
<employees>
<employee id="2">
<name> Name2 </name>
<email> email_New <email>
</employee>
<employee id="3">
<name> Name3 </name>
<email> email3 <email>
</employee>
</employees>
they should be merged to a xml file like this:
<employees>
<employee id="1">
<name> Name1 </name>
<email> email1 <email>
</employee>
<employee id="2">
<name> Name2 </name>
<email> email_New <email>
</employee>
<employee id="3">
<name> Name3 </name>
<email> email3 <email>
</employee>
</employees>
Actually, I'd like to use the update.xml to update the orginal.xml :
new employee in update.xml should be added to original.xml
modified employee information in update.xml should overwrite the corresponding employee node.
I know a little of XSLT, but my knowledge is not enough to figure out the right XSLT for the merge.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…