private void RemoveComments(XDocument document) { var comments = document.DescendantNodes().OfType<XComment>().ToArray(); foreach(var comment in comments) { comment.Remove(); } }