Я хочу удалить атрибуты всех тегов из XML (я хочу сохранить только теги и их внутреннее значение). Какая' Самый простой способ сделать это в C #?
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();
foreach (XmlElement el in nodes.SelectNodes(".//*")) {
el.Attributes.RemoveAll();
}