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, AllowMultiple=true) The belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see Attributes That Control XML Serialization. An XML document usually contains XML elements, each of which consists of three parts: an opening tag with possible attributes, a closing tag, and the data between the tags. XML tags can be nested--that is, the data between tags can also be XML elements. This capacity of one element to enclose another allows the document to contain hierarchies of data. An XML element can also include attributes. Apply the to public fields or public read/write properties to control characteristics of the XML elements such as the element name and namespace. The can be applied multiple times to a field that returns an array of objects. The purpose of this is to specify (through the property) different types that can be inserted into the array. For example, the array in the following C# code accepts both strings and integers. public class Things{ [XmlElement(Type = typeof(string)), XmlElement(Type = typeof(int))] public object[] StringsAndInts; } This results in XML that might resemble the following. <Things> <string>Hello</string> <int>999</int> <string>World</string> </Things> Note that when you apply the multiple times without specifying an property value, the elements are named after the type of the acceptable objects. If you apply the to a field or property that returns an array, the items in the array are encoded as a sequence of XML elements. In contrast if an is not applied to such a field or property, the items in the array are encoded as a sequence of elements, nested under an element named after the field or property. (Use the and attributes to control how an array is serialized.) You can set the property to specify a type that is derived from the type of the original field or property--that is, the field or property to which you have applied the . If a field or property returns an , you can apply multiple instances of the to the member. For each instance, set the property to a type of object that can be inserted into the array. For more information about using attributes, see Extending Metadata Using Attributes. You can use the word XmlElement in your code instead of the longer . Indicates that a public field or property represents an XML element when the serializes or deserializes the object that contains it. Constructor 1.0.5000.0 2.0.0.0 4.0.0.0 To be added Initializes a new instance of the class. Constructor 1.0.5000.0 2.0.0.0 4.0.0.0 By default, the uses the member name as the XML element name when serializing a class instance. For example, a field named Vehicle generates an XML element named Vehicle. However if you need a different element, such as Cars, pass it in the parameter. Initializes a new instance of the class and specifies the name of the XML element. The XML element name of the serialized member. Constructor 1.0.5000.0 2.0.0.0 4.0.0.0 Use the parameter to specify a type that is derived from a base class. For example, suppose a property named MyAnimal returns an Animal object. You want to enhance the object, so you create a new class named Mammal that inherits from the Animal class. To instruct the to accept the Mammal class when it serializes the MyAnimal property, pass the of the Mammal class to the constructor. Initializes a new instance of the class and specifies a type for the member to which the is applied. This type is used by the when serializing or deserializing object that contains it. The of an object derived from the member's type. Constructor 1.0.5000.0 2.0.0.0 4.0.0.0 By default, the uses the member name as the XML element name when serializing a class instance. For example, a field named Vehicle generates an XML element named Vehicle. However, if you need a different element, such as Cars, pass it in the parameter. Use the parameter to specify a type that is derived from a base class. For example, suppose a property named MyAnimal returns an Animal object. You want to enhance the object, so you create a new class named Mammal that inherits from the Animal class. To instruct the to accept the Mammal class when it serializes the MyAnimal property, pass the of the Mammal class to the constructor. Initializes a new instance of the and specifies the name of the XML element and a derived type for the member to which the is applied. This member type is used when the serializes the object that contains it. The XML element name of the serialized member. The of an object derived from the member's type. Property 1.0.5000.0 2.0.0.0 4.0.0.0 System.String To be added: an object of type 'string' 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 type that is mapped to a string, apply the with its property set to the XML Schema type. It is possible that this can change the serialization format, not 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 Schema attribute. For more information about XML 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 (XSD) data type of the XML element generated by the . Property 1.0.5000.0 2.0.0.0 4.0.0.0 System.String To be added: an object of type 'string' Specify an if you want the name of the generated XML element to differ from the member's identifier. You can set the same value to more than one class member if the generated XML document uses XML namespaces to distinguish between the identically named members. For details on how to use namespaces and prefixed names in the XML document, see the class. Gets or sets the name of the generated XML element. Property 1.0.5000.0 2.0.0.0 4.0.0.0 System.Xml.Schema.XmlSchemaForm To be added: an object of type 'System.Xml.Schema.XmlSchemaForm' The property determines whether an XML element is qualified or unqualified. The property conforms to the World Wide Web Consortium (www.w3.org) 1999 specification, "Namespaces in XML". If the property is set to any value, attempting to set the property to XmlSchemaForm.Unqualified throws an exception. The default setting, XmlSchemaForm.None, instructs the to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the uses the elementFormDefault and attributeFormDefault values to determine whether an element or attribute is qualified. The following XML code shows a schema: <schema elementFormDefault="qualified" attributeFormDefault="unqualified"... > <element name="Name"/> <attribute name="Number"/> </schema> When the reads the schema, the value for both the Name and Number is XmlSchemaForm.None, but the Name element is qualified, while the Number element is unqualified. Gets or sets a value that indicates whether the element is qualified. Property 1.0.5000.0 2.0.0.0 4.0.0.0 System.Boolean To be added: an object of type 'bool' The XML schema specification for structures allows an XML document to explicitly signal that an element's content is missing. Such an element contains the attribute xsi:nil set to true. For more information, see the World Wide Web Consortium (www.w3.org) specification, "XML Schema Part 1: Structures". If the property is set to true, the xsi:nil attribute is generated for class members that have been set to null. For example if you set a field named MyStringArray to null, the generates the following XML code. <MyStringArray xsi:nil = "true" /> If the property is false, no XML element is generated for class members that have been set to null. You cannot apply the property to a member typed as a value type because a value type cannot contain null. Additionally, you cannot set this property to false for nullable value types. When such types are null, they will be serialized by setting xsi:nil to true. Gets or sets a value that indicates whether the must serialize a member that is set to null as an empty tag with the xsi:nil attribute set to true. Property 1.0.5000.0 2.0.0.0 4.0.0.0 System.String To be added: an object of type 'string' The property conforms to the World Wide Web Consortium (www.w3.org) specification, "Namespaces in XML". To create namespaces that are associated with a prefix, you must create an that contains the namespaces and prefixes used in the XML document. As you set the namespace for each , it must match one of the namespaces in the . When the XML is generated, each array is correctly prefixed with the prefix associated with the specified namespace. Gets or sets the namespace assigned to the XML element that results when the class is serialized. Property 2.0.0.0 4.0.0.0 System.Int32 To be added. Use the enumeration to instruct the to generate code that sets the property. Once the property has been used on one public property or field in a type, it must be applied to all public properties and fields for that type and all inherited types. Gets or sets the explicit order in which the elements are serialized or deserialized. Property 1.0.5000.0 2.0.0.0 4.0.0.0 System.Type To be added: an object of type 'System.Type' Use the property to specify a derived type for a field or property. If a field or property returns an , you can apply multiple instances of the to the member. For each instance, set the property to a type of object that can be inserted into the array. Gets or sets the object type used to represent the XML element.