Condividi tramite


XmlAttributes.XmlAttribute Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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)

Syntax

'Declaration
Public Property XmlAttribute As XmlAttributeAttribute
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.

Remarks

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.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.