Indicates to the XmlSerializer that the member must be treated as XML text when the class that contains it is serialized or deserialized.
Assembly: System.Xml (in System.Xml.dll)
This API supports the product infrastructure and is not intended to be used directly from your code. Returns a value that indicates whether this instance is equal to a specified object.(Inherited from Attribute.)
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)
Returns the hash code for this instance.(Inherited from Attribute.)
When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.(Inherited from Attribute.)
When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.(Inherited from Attribute.)
Returns a string that represents the current object.(Inherited from Object.)
|_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)|
Maps a set of names to a corresponding set of dispatch identifiers.(Inherited from Attribute.)
|_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)|
Retrieves the type information for an object, which can be used to get the type information for an interface.(Inherited from Attribute.)
Retrieves the number of type information interfaces that an object provides (either 0 or 1).(Inherited from Attribute.)
|_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)|
Provides access to properties and methods exposed by an object.(Inherited from Attribute.)
Only one instance of theclass can be applied in a class.
You can apply theto public fields and public read/write properties that return primitive and enumeration types.
By default, the XmlSerializer serializes a class member as an XML element. However, if you apply the to a member, the XmlSerializer translates its value into XML text. This means that the value is encoded into the content of an XML element.
The XML Schema Definition Tool (Xsd.exe) occasionally generates the when creating classes from an XML Schema definition (XSD) file. This occurs when the schema contains a complexType with mixed content; in that case, the corresponding class contains a member that returns a string array to which the is applied. For example, when the Xml Schema Definition tool processes this schema:
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="LinkList" type="LinkList" /> <xs:complexType name="LinkList" mixed="true"> <xs:sequence> <xs:element minOccurs="1" maxOccurs="1" name="id" type="xs:int" /> <xs:element minOccurs="0" maxOccurs="1" name="name" type="xs:string" /> <xs:element minOccurs="0" maxOccurs="1" name="next" type="LinkList" /> </xs:sequence> </xs:complexType> </xs:schema>
the following class is generated (extra spaces and remarks have been removed):
For more information about using attributes, see Extending Metadata Using Attributes.
You can use the word XmlText in your code instead of the longer.
Available since 8
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 8.1
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Introducing XML Serialization
How to: Specify an Alternate Element Name for an XML Stream
Controlling XML Serialization Using Attributes
Examples of XML Serialization
XML Schema Definition Tool (Xsd.exe)