using System; using System.Collections.Generic; using System.Linq; using System.Xml; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(@" "); XmlNode root = xmlDoc.DocumentElement; List disabledNodes = new List(); try { foreach (XmlNode node in root.ChildNodes.Cast() .Where(child => child.Attributes["disabled"] != null && Convert.ToBoolean(child.Attributes["disabled"].Value))) { Console.WriteLine("Removing:"); Console.WriteLine(node.OuterXml); root.RemoveChild(node); } } catch (Exception Ex) { Console.WriteLine("Exception, as expected"); } Console.WriteLine(); Console.WriteLine(root.OuterXml); Console.ReadKey(); } } }