// 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) { string[] files = { @"C:\fil1.xml", @"C:\fil2.xml" }; XmlDocument newdoc = new XmlDocument(); XmlElement root = newdoc.CreateElement("root"); newdoc.AppendChild(root); XmlElement menu = newdoc.CreateElement("menu"); root.AppendChild(menu); for(int i = 0; i < files.Length; i++) { XmlDocument olddoc = new XmlDocument(); olddoc.Load(files[i]); XmlNodeList elements = olddoc.GetElementsByTagName("menuitem"); foreach(XmlNode element in elements) { XmlElement menuitem = newdoc.CreateElement("menuitem"); menuitem.SetAttribute("id", ((XmlElement)element).GetAttribute("id")); menu.AppendChild(menuitem); } } newdoc.Save(@"C:\allfiles.xml"); } }