// 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.Collections.Generic; using System.Xml; namespace E { public class Program { public static void Main(string[] args) { string addxml = @" Jesper hehe "; XmlDocument adddoc = new XmlDocument(); adddoc.LoadXml(addxml); Dictionary repl = new Dictionary(); foreach(XmlElement elm in adddoc.SelectSingleNode("//NewDataSet/Results").ChildNodes) { repl.Add(elm.Name, elm.FirstChild.Value); } string basexml = @" TextBox String Yes 1 Navn Multiline Other Yes 2 Adresse "; XmlDocument basedoc = new XmlDocument(); basedoc.LoadXml(basexml); foreach(XmlElement fields in basedoc.SelectNodes("//NewDataSet/Fields")) { string id = fields.SelectSingleNode("Id").FirstChild.Value; fields.SelectSingleNode("Text").AppendChild(basedoc.CreateTextNode(repl[id])); } basedoc.Save(Console.Out); } } }