Adds a child element to an XML node. - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

Adds a child element to an XML node.

Demo Code


using System.Xml;

public class Main{
        /// <summary>
        /// Adds a child element to an XML node.
        /// </summary>
        /// <param name="parentNode">The parent XML node.</param>
        /// <param name="name">The child element name.</param>
        /// <returns>The new child XML element.</returns>
        public static XmlNode AddElement(XmlNode parentNode, string name)
        {//from www .  ja  v a  2  s .  c  o  m
            XmlNode element = parentNode.OwnerDocument.CreateElement(name);
            parentNode.AppendChild(element);
            return element;
        }
}

Related Tutorials