Gets or sets an object that specifies how the XmlSerializer serializes a public field or public read/write property as an XML attribute.
Assemblies: System.Xml (in System.Xml.dll)
System.Xml.XmlSerializer (in System.Xml.XmlSerializer.dll)
By default, if no attribute is applied to a public field or public read/write property, it is serialized as an XML element. You can also instruct the XmlSerializer to generate an XML attribute by applying an XmlAttributeAttribute to the field or property.
The property allows you to override the default serialization, as well as the serialization controlled by applying an XmlAttributeAttribute to the member. To do this, create an XmlAttributeAttribute and set its properties (such as AttributeName). Assign the new object to the property of an XmlAttributes object. Add the XmlAttributes object to an XmlAttributeOverrides object and specify the type of the object that contains the field or property, and the name of the field or property. Lastly, create an XmlSerializer using the XmlAttributeOverrides object and call the Serialize or Deserialize method.
The following example serializes a class named Group that contains a property named GroupName; the GroupName property is serialized as an XML attribute. The example creates an XmlAttributeOverrides and an XmlAttributes object to override the default serialization of the field. The example then creates an XmlAttributeAttribute to specifically override the property, and the object is set to the property The XmlAttributes object is added to the XmlAttributeOverrides object with the name of the overridden member specified. Finally, an XmlSerializer is constructed and returned using the XmlAttributeOverrides object.