private static XElement RemoveAllNamespaces(XElement xmlDocument) { if (!xmlDocument.HasElements) { XElement xElement = new XElement(xmlDocument.Name.LocalName); xElement.Value = xmlDocument.Value; return xElement; } return new XElement(xmlDocument.Name.LocalName, xmlDocument.Elements().Select(el => RemoveAllNamespaces(el))); }
XmlDocument doc = new XmlDocument()doc.Load(ms);doc.DocumentElement.Attributes.RemoveAll();
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.