// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Xml; class MainClass { public static void Main(string[] args) { XmlDocument doc = new XmlDocument(); doc.Load("C:\\test.xml"); doc.Save(Console.Out); XmlNodeList elements = doc.GetElementsByTagName("en"); foreach(XmlNode element in elements) { XmlNodeList subelements = element.ChildNodes; for(int i = subelements.Count - 1; i >= 0 ; i--) { element.RemoveChild(subelements[i]); } XmlNode add = doc.CreateElement("d"); add.AppendChild(doc.CreateTextNode("slettet")); element.AppendChild(add); } doc.Save(Console.Out); } }