2010-08-23 22 views

risposta

2
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(); 
3

foreach (XmlElement el a nodes.SelectNodes (".//*")) {

el.Attributes.RemoveAll();

}

Problemi correlati