CSharp examples for System.Xml:XML Namespace
Remove All XML Namespaces
using System.Xml.Linq; using System.Text.RegularExpressions; using System.Xml; using System.Text; using System.Linq; using System.IO;/*from ww w. j a va 2s .c om*/ using System.Collections.Generic; using System; public class Main{ private static XElement RemoveAllNamespaces(XElement xmlDocument) { if (!xmlDocument.HasElements) { var xElement = new XElement(xmlDocument.Name.LocalName) {Value = xmlDocument.Value}; return xElement; } return new XElement(xmlDocument.Name.LocalName, xmlDocument.Elements().Select(el => RemoveAllNamespaces(el))); } }