CSharp examples for System.Xml:XML Attribute
Adds an attribute to an XML node.
using System.Xml; public class Main{ /// <summary> /// Adds an attribute to an XML node. /// </summary> /// <param name="node">The XML node.</param> /// <param name="name">The attribute name.</param> /// <param name="value">The attribute value.</param> public static void AddAttribute(XmlNode node, string name, object value) {//w w w. j a v a 2 s . c om XmlAttribute attr = node.OwnerDocument.CreateAttribute(name); attr.Value = value.ToString(); node.Attributes.Append(attr); } }