fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Xml;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. XmlDocument xmlDoc = new XmlDocument();
  13.  
  14. xmlDoc.LoadXml(@"<Parts>
  15. <Part name=""Part1"" disabled=""true""></Part>
  16. <Part name=""Part2"" disabled=""false""></Part>
  17. <Part name=""Part3"" ></Part>
  18. <Part name=""Part4"" disabled=""true""></Part>
  19. </Parts>");
  20.  
  21. XmlNode root = xmlDoc.DocumentElement;
  22. List<XmlNode> disabledNodes = new List<XmlNode>();
  23.  
  24. foreach (XmlNode node in root.ChildNodes.Cast<XmlNode>()
  25. .Where(child => child.Attributes["disabled"] != null &&
  26. Convert.ToBoolean(child.Attributes["disabled"].Value)))
  27. {
  28. root.RemoveChild(node);
  29. }
  30.  
  31. Console.WriteLine(root.OuterXml);
  32. }
  33. }
  34. }
  35.  
Runtime error #stdin #stdout 0.08s 41160KB
stdin
Standard input is empty
stdout
Standard output is empty