CSharp examples for System.Xml:XML Document
Create XML Document
using System.Xml; public class Main{ public static XmlDocument CreateDocument(string rootName) {//from ww w. j a v a 2 s . c om if (string.IsNullOrEmpty(rootName)) return null; var document = new XmlDocument(); document.InsertBefore(document.CreateXmlDeclaration("1.0", "UTF-8", null), document.DocumentElement); document.AppendChild(document.CreateElement(rootName)); return document; } }