"Urs Vogel" <uv****@msn.com> wrote in message news:O$**************@TK2MSFTNGP14.phx.gbl...
What I didn't achieve is changing the Value of a node (created with createElement), it claims that it's the wrong node type.
This is correct. Elements have no Value in the DOM. They have
child nodes. Think of them as containers of other nodes, not
terminal nodes.
When cloning the node and reassigning the child nodes of the original node to the cloned node,
I'd like to see the code of exactly how these reassignments are
being performed before commenting on why the child nodes
may not be visible in the InnerXml (if the nodes are properly
moved from the original element's children to the new - cloned
- element then it should work); but did you know you could also
do a "deep copy" clone by passing a boolean argument of true
to the CloneNode( bool) method if all you're going to do is
copy the original element's children anyway.
To make it simple. How do I change the value of a node without loosing its children?
Recognize the difference between nodes and elements (Elements
are nodes, but not all nodes are elements).
Then change the child nodes of the element. All an element has,
besides it's identity (QName: in the Prefix, LocalName and Name-
spaceUri properties), and attributes (GetAttributes(int)) -- is it's
children.
Also (purely speculating), make sure if you're cloning the element
and changing it, that you remember to ReplaceChild( ) the new
element for the original element at the appropriate position in the
document's node tree. It's not enough to merely CreateElement( )
as you must also remember to attach that element at the correct
spot in its owner document.
Derek Harmon