Mono Class Library: System.Xml NamespaceSystem.Xml.XmlAttribute Class |
See Also: XmlAttribute Members
System.Object
System.Xml.XmlNode
System.Xml.XmlAttribute
|
Attributes are contained in the XmlNode.Attributes property of element nodes. In the Xml below, "attribute" is an attribute of the "example" element.
xml Example <example attribute="value"/>The following example shows how an attribute is programmatically added into an Xml document.
[Edit]
C# Example using System; using System.Xml; class MainClass { public static void Main(string[] args) { Console.WriteLine("Hello World!"); DomDemo(); } public static void DomDemo() { XmlDocument doc=new XmlDocument(); doc.LoadXml("<root />"); XmlAttribute a=doc.CreateAttribute("Foo"); a.Value="Bar"; doc.DocumentElement.Attributes.Append(a); Console.Out.WriteLine(doc.OuterXml); } }
Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0