using System;
using System.IO;
using System.Xml;public class Sample { public static void Main() { XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
"<title>Pride And Prejudice</title>" +
"</book>"); XmlNode root = doc.DocumentElement; //Remove all attribute and child nodes.
root.RemoveAll(); Console.WriteLine("Display the modified XML...");
doc.Save(Console.Out); }
}
using System.IO;
using System.Xml;public class Sample { public static void Main() { XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
"<title>Pride And Prejudice</title>" +
"</book>"); XmlNode root = doc.DocumentElement; //Remove all attribute and child nodes.
root.RemoveAll(); Console.WriteLine("Display the modified XML...");
doc.Save(Console.Out); }
}
doc.Load(@"../../test.xml");
doc.DocumentElement.RemoveAll();
doc.Save(@"../../test.xml");删除除根结点以外的所有结点...