javascript - Add one xml element into another xml -
please let me know how following thing.
xml document 1 :
<tag1 id="id1" name="myname"> <tag_child1 child1id="child1"></tag_child1> </tag1>
xml document 2 :
<tag_child2> <tagchild2_child3 child_childid = "child_child3"> </tagchild2_child3> </tag_child2>
final document :
<tag1 id="id1" name="myname"> <tag_child1 child1id="child1"></tag_child1> <!-- document 2 --> <tag_child2> <tagchild2_child3 child_childid = "child_child3"> </tagchild2_child3> </tag_child2> </tag1>
i tried using appendchild() function in javascript.but wasn't able it. please help. thanks
pulls out glass ball...
you have been trying
nodefromdoc1.appendchild(nodefromdoc2);
and error said cannot append child nodes not belong different document.
try
var othernode = doc1.importnode(nodefromdoc2, true); nodefromdoc1.appendchild(othernode);
see: https://developer.mozilla.org/en-us/docs/web/api/document.importnode
Comments
Post a Comment