// 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.IO; using System.Text; using System.Xml; class MainClass { public static void Main(string[] args) { StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); xtw.Formatting = Formatting.Indented; xtw.WriteStartDocument(); xtw.WriteStartElement("all"); xtw.WriteStartElement("one"); xtw.WriteString("aaa"); xtw.WriteEndElement(); xtw.WriteStartElement("one"); xtw.WriteString("bbb"); xtw.WriteEndElement(); xtw.WriteEndElement(); xtw.WriteEndDocument(); xtw.Close(); sw.Close(); Console.WriteLine(sw.ToString()); } }