我希望在将其发送给客户端之前从 XElement 中删除我的所有 XComment。
由于某种原因它不起作用并且 removeMe.Count()=0
有什么想法吗?
{
// ...
myXml = XElement.Load(myPath);
var removeMe=myXml.Descendants().Where(x => x.NodeType == XmlNodeType.Comment);
removeMe.Count(); // this is 0 , (not what i was expected)
removeMe.Remove();
//...
string myResponseStr = myXml.ToString(SaveOptions.None);
context.Response.ContentType = "text/plain";
context.Response.Write(myResponseStr);
}
xml文件可以是这样的
<user>
<name> Elen </name>
<userSettings>
<color> blue </color> <!-- the theme color of the page -->
<layout> horizontal </layout> <!-- layout choise -->
<!-- more settings -->
</userSettings>
</user>