I was hoping to remove all XComment from the XElement before sending it to the client.
for some reason it doesn't work and removeMe.Count () = 0
any thoughts?
{ // ... 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 file may be the same
<user> <name> Elen </name> <userSettings> <color> blue </color> <layout> horizontal </layout> </userSettings> </user>
source share