Clive Dixon wrote:
Given an XmlNode with namespace (NamespaceURI has a value), I want to be
able to make a clone of it (XmlNode.CloneNode) but without the namespace.
How can I strip the namespace from a node?
If the namespace is different then the new node is a not a clone of the
old node.
What you can do is create a new node in a different namespace
respectively in no namespace:
XmlDocument doc = new XmlDocument();
doc.LoadXml(@"<foo xmlns=""http://example.com/ns1""/>");
XmlNode foo1 = doc.DocumentElement;
XmlNode foo2 = doc.CreateNode(foo1.NodeType, foo1.LocalName, "");
doc.ReplaceChild(foo2, foo1);
Note that if the old node has any child elements then you need to apply
the same approach to the child elements as well as those inherit the
namespace.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/