title: How to remove xmlns attribute with .NET XML API
body: <p>XmlElement.Attributes.Remove* methods are working fine for arbitrary attributes resulting in the removed attributes being removed from XmlDocument.OuterXml property. Xmlns attribute however is different. Here is an example:</p>
  
  <pre><code>XmlDocument doc = new XmlDocument();
  doc.InnerXml = @"&lt;Element1 attr1=""value1"" xmlns=""http://mynamespace.com/"" attr2=""value2""/&gt;";
  doc.DocumentElement.Attributes.RemoveNamedItem("attr2");
  Console.WriteLine("xmlns attr before removal={0}", doc.DocumentElement.Attributes["xmlns"]);
  doc.DocumentElement.Attributes.RemoveNamedItem("xmlns");
  Console.WriteLine("xmlns attr after removal={0}", doc.DocumentElement.Attributes["xmlns"]);
  </code></pre>
  
  <p>The resulting output is</p>
  
  <pre><code>xmlns attr before removal=System.Xml.XmlAttribute
  xmlns attr after removal=
  &lt;Element1 attr1="value1" xmlns="http://mynamespace.com/" /&gt;
  </code></pre>
  
  <p>The attribute seems to be removed from the Attributes collection, but it is not removed from XmlDocument.OuterXml.
  I guess it is because of the special meaning of this attribute.</p>
  
  <p>The question is how to remove the xmlns attribute using .NET XML API.
  Obviously I can just remove the attribute from a String representation of this, but I wonder if it is possible to do the same thing using the API.</p>
  
  <p>@Edit: I'm talking about .NET 2.0.</p>