Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Créer un document XML avec des noeuds

Utilisation,de,la,classe,'XmlTextReader',pour,lire,un,document,XML
{filelink=16411}

/*
  GNU General Public License version 2 (GPLv2)
  http://cbasetest.codeplex.com/license
 */
nomspace 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 documentXML, string nom)
        {
            return CreateXmlNode(documentXML, nom, string.Empty);
        }
 
        public static XmlNode CreateXmlNode(XmlDocument documentXML, string nom, string value)
        {
            XmlNode noeud = documentXML.CreateNode(XmlNodeType.Element, nom, string.Empty);
            noeud.AppendChild(documentXML.CreateTextNode(value));
            return noeud;
        }
    }
}

No comments yet.

Leave a Comment