XmlAttribute Property

XmlAttributes.XmlAttribute Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets an object that specifies how the XmlSerializer serializes a public field or public read/write property as an XML attribute.

Namespace:  System.Xml.Serialization
Assembly:  System.Xml.Serialization (in System.Xml.Serialization.dll)

public XmlAttributeAttribute XmlAttribute { get; set; }

Property Value

Type: System.Xml.Serialization.XmlAttributeAttribute
An XmlAttributeAttribute that controls the serialization of a public field or read/write property as an XML attribute.

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 XmlAttribute 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 XmlAttribute 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. Last, create an XmlSerializer using the XmlAttributeOverrides object and call the Serialize or Deserialize method.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft