If I have two xml documents and store them into two javascript variables (xA and xB), how would I merge them together(with overwriting)?
For example
xA is
<cat>
<name type="asdf" >
Bob
</name>
<color>
brown
</color>
<length>
8
</length>
</cat>
xB is
<root>
<cat>
<name type="fdsa" >
Bob
</name>
<color>
black
</color>
<weight>
14
</weight>
</cat>
</root>
xB merge onto xA (stored as a variable xC) is
<root>
<cat>
<name type="fdsa" >
Bob
</name>
<color>
black
</color>
<length>
8
</length>
<weight>
14
</weight>
</cat>
</root>
And then I can print xC as string or save it, etc. How can I do this kind of merge in javascript?