我想从XML中删除所有标签的属性(我只想保留标签及其内部值)。在C#中执行此操作的最简单方法是什么? 最佳答案 staticvoidremoveAllAttributes(XDocumentdoc){foreach(vardesindoc.Descendants())des.RemoveAttributes();}用法:vardoc=XDocument.Load(path);//Or.Parse("xml");removeAllAttributes(doc);stringres=doc.ToString();