I attempting to add a new "PropertyGroup" element to the following XML file
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectGuid>{00AA7ECA-95A0-0000-0000-AD4D2E056BFE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>testnS</RootNamespace>
<AssemblyName>testname</AssemblyName>
<PluginId>4B84E5C0-EC2B-4C0C-8B8E-3FAEB09F74C6</PluginId>
</PropertyGroup>
</Project>
The code I am using is as follows (note there is other logic that has been removed) :
XmlTextReader reader = new XmlTextReader(filename);
XmlDocument doc = new XmlDocument();
doc.Load(reader);
reader.Close();
XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable);
ns.AddNamespace("x", "http://schemas.microsoft.com/developer/msbuild/2003");
XmlElement root = doc.DocumentElement;
XmlNode refNode = root.SelectSingleNode("x:Project", ns);
root.SelectSingleNode("Project", ns);
XmlElement newElement = doc.CreateElement("PropertyGroup", "http://schemas.microsoft.com/developer/msbuild/2003");
newElement.InnerXml = "<value>test</value>";
root.InsertAfter(newElement, refNode);
doc.Save(filename);
This yields the following new element in the XML document :
<PropertyGroup>
<value xmlns="">test</value>
</PropertyGroup>
How do I get rid of the namespace declaration on the element?