Create Xml Document, Node : DOM « XML « C# / C Sharp

Create Xml Document, Node

//GNU General Public License version 2 (GPLv2)
namespace SDFL.Helper
    using System;
    using System.Text;
    using System.Xml;

    public class XMLHelper
        public static XmlDocument CreateXmlDocument()
            return CreateXmlDocument(new Version(1, 0), Encoding.UTF8);

        public static XmlDocument CreateXmlDocument(Version version, Encoding encoding)
            XmlDocument document = new XmlDocument();
            document.AppendChild(document.CreateXmlDeclaration(version.ToString(), encoding.BodyName, string.Empty));
            return document;

        public static XmlNode CreateXmlNode(XmlDocument xmlDocument, string name)
            return CreateXmlNode(xmlDocument, name, string.Empty);

        public static XmlNode CreateXmlNode(XmlDocument xmlDocument, string name, string value)
            XmlNode node = xmlDocument.CreateNode(XmlNodeType.Element, name, string.Empty);
            return node;


Related examples in the same category

1.DOM feature check
2.Load String from xml element
3.Load boolean value from xml element
4.Get integer value from xml element
5.Get attribute from XmlNode
6.Set Xml Node Value
7.Get Value String from Xml
8.Get InnerXml without changing the spacing
9.Get Inner Xml
10.Add Xml Element
11.Returns the InnerText value from a node or string.Empty if the node is null.
12.Sets the inner text in a node. If the node doesn't exist, it creates a new one and adds the text to it.