System.Xml
[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00]
1.0.5000.0
2.0.0.0
4.0.0.0
To be added
System.Attribute
System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.ReturnValue | System.AttributeTargets.All)
The belongs to a family of attributes that controls how the serializes and deserializes an object (through its and methods). For a complete list of similar attributes, see Attributes That Control XML Serialization.
Only one instance of the class can be applied in a class.
You can apply the to public fields and public read/write properties that return primitive and enumeration types.
You can apply the to a field or property that returns an array of strings. You can also apply the attribute to an array of type but you must set the property to string. In that case, any strings inserted into the array are serialized as XML text.
The can also be applied to a field that returns an or an array of objects.
By default, the serializes a class member as an XML element. However, if you apply the to a member, the 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):
code reference: XmlTextAttribute#0
For more information about using attributes, see Extending Metadata Using Attributes.
You can use the word XmlText in your code instead of the longer .
Indicates to the that the member must be treated as XML text when the class that contains it is serialized or deserialized.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
You can override the way that the serializes a public field or public read/write property by creating an , and setting its property to an . For more details, see the class.
Initializes a new instance of the class.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
You can override the way that the serializes a public field or public read/write property by creating an , and setting its property to an . For more details, see the class.
Initializes a new instance of the class.
The of the member to be serialized.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
To be added: an object of type 'string'
Setting the property to an XML Schema simple data type affects the format of the generated XML. For example, setting the property to "date" causes the generated text to be formatted in the general date style, for example: 2001-08-31. By contrast, setting the property to "dateTime" results in a specific instant as defined by the International Organization for Standardization document 8601, "Representations of Dates and Times", for example: 2001-08-15T06:59:11.0508456-07:00.
The effect of setting the property can also be seen when using the XML Schema Definition Tool (Xsd.exe) to generate the XML Schema for a compiled file. For more information on using the tool, see The XML Schema Definition Tool and XML Serialization.
The following table lists the XML Schema simple data types with their .NET equivalents.
For the XML Schema base64Binary and hexBinary data types, use an array of structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema time and date data types, use the type and apply the with the set to "date" or "time".
For every XML Schema data type that is mapped to a string, apply the with its property set to the XML Schema data type. Note that this does not change the serialization format, only the schema for the member.
The property is case-sensitive, so you must set it exactly to one of the XML Schema data types.
Passing binary data as an XML element is more efficient than passing it as an XML attribute.
For more information about XML Schema data types, see the World Wide Web Consortium (www.w3.org) document named "XML Schema Part 2: Datatypes".
-
XSD data type
.NET data type
-
anyURI
-
base64Binary
Array of objects
-
boolean
-
byte
-
date
-
dateTime
-
decimal
-
double
-
ENTITY
-
ENTITIES
-
float
-
gDay
-
gMonth
-
gMonthDay
-
gYear
-
gYearMonth
-
hexBinary
Array of objects
-
ID
-
IDREF
-
IDREFS
-
int
-
integer
-
language
-
long
-
Name
-
NCName
-
negativeInteger
-
NMTOKEN
-
NMTOKENS
-
normalizedString
-
nonNegativeInteger
-
nonPositiveInteger
-
NOTATION
-
positiveInteger
-
QName
-
duration
-
string
-
short
-
time
-
token
-
unsignedByte
-
unsignedInt
-
unsignedLong
-
unsignedShort
Gets or sets the XML Schema definition language (XSD) data type of the text generated by the .
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Type
To be added: an object of type 'System.Type'
The property can only be set to primitive types and enumerations.
The can also be applied to a field that returns an or an array of objects.
You can apply the to a field or property that returns an array of strings. You can also apply the attribute to an array of type but you must set the property to string. In that case, any strings inserted into the array are serialized as XML text.
Gets or sets the type of the member.