2010-08-23 33 views

Trả lời

2
static void removeAllAttributes(XDocument doc) 
{ 
    foreach (var des in doc.Descendants()) 
     des.RemoveAttributes(); 
} 

Cách sử dụng:

var doc = XDocument.Load(path); //Or .Parse("xml"); 
removeAllAttributes(doc); 

string res = doc.ToString(); 
3

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

el.Attributes.RemoveAll();

}

Các vấn đề liên quan