Altova Mailing List Archives
>microsoft.public.xml Archive Home
>Thread Prev - Why do elements appear to get "moved" between doms
Re: Why do elements appear to get "moved" between doms
Date: 7/19/2006 1:00:00 PM
"Thomas Malia" <tommalia@w...> wrote in message news:OahTSxpqGHA.4508@T...... > Using the code below, the process of appending elements from DOM 'd' to DOM > 'd2' appears to acutally Move them from one dom to the other. Is this the > correct behavior for for this process? If so, why? > All msxml nodes in an apartment are managed as a single heap. The tree graphing ownership of the nodes will contain documents at the root. It is a reasonably easy thing to re-parent a node that is currently owned by one document into another since they are technically all in the same space. Whether this is 'correct' is debatable but in terms of standards no it isn't. If you tried to do this with other implementations you are likely to get an error. Even if you tried to do it with cloneNode() you'd still get an error. The standard view is that nodes belong to a document space and that each document has it's own space or 'heap' of nodes. You would need to use importNode() to move the node from one document to the other. MSXML6 has added the importNode() function so that code written for standard DOM should work. Anthony.