August 2003
Beginner to intermediate
600 pages
12h 57m
English
To create an XmlAttribute, the XmlDocument provides the CreateAttribute method. This method creates an XmlAttribute node linked to the current XmlDocument. The value must be set after the XmlAttribute is created (see Listing 11.18).
C#
XmlAttribute newAttribute = XmlDoc.CreateAttribute("att");
newAttribute.Value = "val";
VB
Dim newAttribute As XmlDoc.CreateAttribute("att")
newAttribute.Value = "val"
|
After creating the attribute, you must add it to an XmlElement. The XmlElement's SetAttributeNode method provides this functionality. The SetAttributeNode takes the newly created XmlAttribute and adds it to the XmlElement's list of attributes. The SetAttributeNode method has an overload that takes two parameters: ...
Read now
Unlock full access