What's the easiest way to remove all attributes from a XML in C#?
foreach (XmlElement el in nodes.SelectNodes(".//*")) {
el.Attributes.RemoveAll();
}
static void removeAllAttributes(XDocument doc)
{
foreach (var des in doc.Descendants())
des.RemoveAttributes();
}
Usage:
var doc = XDocument.Load(path); //Or .Parse("xml");
removeAllAttributes(doc);
string res = doc.ToString();