public static void Main()
const string xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<Main version=""1.0"" xmlns=""urn:root:v1"">
<Title>Some Value</Title>
<CountryName xmlns=""urn:location:v2"">Australia</CountryName>
var doc = XDocument.Parse(xml);
doc.Descendants().Attributes().Where(x => x.IsNamespaceDeclaration).Remove();
doc.Root.Add(new XAttribute(XNamespace.Xmlns + "root", "urn:root:v1"));
doc.Root.Add(new XAttribute(XNamespace.Xmlns + "loc", "urn:location:v2"));