To remove node from XMLDocument (see Jens answer for removing node form XDocument )
XmlDocument doc = XmlDocument.Load(filename); // or XmlDocument.LoadXml(string) XmlNodeList nodes = doc.SelectNodes("//file"); foreach(XmlNode node in nodes) { node.ParentNode.RemoveChild(node); }
Watch out for a possible possible exception if node.ParentNode is null.
source share