Add Xml Header - CSharp System.Xml

CSharp examples for System.Xml:XML Namespace

Description

Add Xml Header

Demo Code


using System.Xml;
using System.Collections.Generic;
using System;/*from w w  w.j a  v  a  2  s  . c  om*/

public class Main{
        public static XmlDocument AddXmlHeader(XmlDocument xml, string rootTagName)
        {
            XmlNode xmlHead = xml.CreateXmlDeclaration("1.0", "UTF-8", null);
            xml.AppendChild(xmlHead);
            XmlNode xmlRoot = xml.CreateElement(rootTagName);
            xml.AppendChild(xmlRoot);
            return xml;
        }
}

Related Tutorials