XmlAttributes.XmlText Property

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

Gets or sets an object that instructs the XmlSerializer to serialize a public field or public read/write property as XML text.

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

Syntax

'Declaration
Public Property XmlText As XmlTextAttribute
public XmlTextAttribute XmlText { get; set; }

Property Value

Type: System.Xml.Serialization.XmlTextAttribute
An XmlTextAttribute that overrides the default serialization of a public property or field.

Remarks

By default, a public field or public read/write property is serialized as an XML element by the XmlSerializer. However, it can force the field or property to be serialized as XML text by applying an XmlTextAttribute to the field or property.

NoteNote:

The XmlTextAttribute cannot be applied to a field or property that returns an array.

To override the default serialization of a field or property (that does not return an array), create an XmlTextAttribute and assign it to the XmlText property of an XmlAttributes object. Add the XmlAttributes object to an XmlAttributeOverrides object and specify the type of the object that contains the overridden field or property and the name of the overridden field or property.

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.