You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Anuj Seth <an...@sasi.com> on 2000/07/10 16:02:45 UTC

How to use appendChild and importNode?

Hi,

How do I use the appendChild function of DOM_Node?

Basically, I have implemented some code for merging two XML files into
one. I have successfully identified which node to add the new node to,
but the appendChild function throws an exception every time.

Some code snippet is shown below,

doc1.importNode(doc2, true);

where doc1 is the node to which doc2 is to be added to as a child node.
doc2 can have several child nodes as well. I can guarantee that both
doc1 and doc2 are valid DOM_Node's. I've ensured this by printing its
name and value before calling the importNode function. I changed the
importNode to appendChild as shown below without any success,

doc1.appendChild(doc2);

doc1 and doc2 are both of type DOM_Node and were retrieved by the
following calls,

doc1 = parser1.getDocument();
doc2 = parser2.getDocument();

Could some one please let me know where the problem might lie?

Thanks a ton,

With Regards,
Anuj