Add XML Attribute - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Add XML Attribute

Demo Code


using System.Xml;

public class Main{
        public static void AddAttribute(XmlNode parent, string name, string value)
        {//from www . j av  a  2 s.c  o m
            if (parent == null || string.IsNullOrEmpty(name))
                return;

            XmlAttribute attribute = parent.OwnerDocument.CreateAttribute(name);
            attribute.Value = value;

            parent.Attributes.Append(attribute);
        }
}

Related Tutorials