CSharp examples for System.Xml:XML Attribute
Create And Add Attribute to XmlNode
using System.Xml; using System;/* w ww . j a v a 2s . co m*/ public class Main{ public static XmlAttribute CreateAndAddAttribute(XmlNode parentNode, string attributeName, string innerText) { XmlAttribute node; if (parentNode.GetType() == typeof(XmlDocument)) node = ((XmlDocument)parentNode).CreateAttribute(attributeName); else node = parentNode.OwnerDocument.CreateAttribute(attributeName); parentNode.Attributes.Append(node); if (innerText != null) node.InnerText = innerText; return node; } public static XmlAttribute CreateAndAddAttribute(XmlNode parentNode, string attributeName) { return CreateAndAddAttribute(parentNode, attributeName); } }