Create XML Element - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

Create XML Element

Demo Code


using System.Xml;
using System.Collections.Generic;
using System;//  w w  w. j a  va2 s . c o  m

public class Main{
        public static XmlElement CreateElement(XmlElement _node, string _name, object _value)
      {
         XmlElement node = _node.OwnerDocument.CreateElement(_name);
         _node.AppendChild(node);
         node.InnerText = _value.ToString();
         return node;
      }
        public static XmlElement CreateElement(XmlElement _node, string _name)
      {
         XmlElement node = _node.OwnerDocument.CreateElement(_name);
         _node.AppendChild(node);
         return node;
      }
        public static XmlElement CreateElement(XmlDocument _doc, string _name)
      {
         XmlElement root = _doc.CreateElement(_name);
         _doc.AppendChild(root);
         return root;
      }
}

Related Tutorials