.NET: Importing an XmlElement with a different element name

Basically I need to rename the XmlElement (which is not possible in .NET afaik).

Is there a way to import the XmlElement and rename the new XmlElement?

XmlElement oldElm; XmlDocument document; 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 in which I import the children into the newly created element ...

Is this possible (in .NET)?

+1


a source to share


1 answer


I don't think this is possible in .NET at the moment using XmlDocument. From what I know and have been able to research, the only way to achieve re-naming of an element is to create a new element and move the elements of the original element under that element.



Here's an example showing you how to rename an element using the W3C DOM (XmlDocument) by moving the child elements.

+1


a source







All Articles