Basicly what I need is to be able to rename an XmlElement (which is not possible in .NET afaik).
Is there a way to ImportNode an XmlElement and rename that new XmlElement?
XmlElement oldElm;
XmlDocument doc;
XmlElement newElm = (XmlElement) doc.ImportNode(oldElm, true);
newElm.Rename(“newElmName”, “urn:newElmNameSpace”);
or something similar…
What I want to avoid is to write a loop where I import the childnodes into a newly created element…
Is this possible (in .NET)?
I don’t think that this is possible in .NET at the moment using the XmlDocument. From what I know and have been able to research the only way to achieve a re-naming of an element is to create a new element and move the origional elements children under this element.
Here is an example showing you how to re-name an element using the W3C DOM (XmlDocument) model by moving the children.