Create Xml Document, Node
//GNU General Public License version 2 (GPLv2)
//http://cbasetest.codeplex.com/license
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);
node.AppendChild(xmlDocument.CreateTextNode(value));
return node;
}
}
}
Related examples in the same category