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.

You can apply the to any public read/write member that returns an array, or provides access to one. For example, a field that returns an array of objects, a collection, an , or any class that implements the interface.

The supports polymorphism--in other words, it allows the to add derived objects to an array. For example, suppose a class named Mammal is derived from a base class named Animal. Further suppose that a class named MyAnimals contains a field that returns an array of Animal objects. To allow the to serialize both the Animal and Mammal type, apply the to the field twice, each time specifying one of the two acceptable types.

You can apply multiple instances of the or to specify types of objects that can be inserted into the array.

The serialization of a field or property that returns an interface or array of interfaces is not supported.

For more information about using attributes, see Extending Metadata Using Attributes.

You can use the word XmlArrayItem in your code instead of the longer .

Represents an attribute that specifies the derived types that the can place in a serialized array.

- 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

  This overload sets the property.

  Use this overload if you want the name of the generated XML element to differ from the member's identifier.

  An XML document that includes namespaces can contain more than one version of an element name. For details, see the property.

  Initializes a new instance of the class and specifies the name of the XML element generated in the XML document.

  The name of the XML element.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  To be added

  Initializes a new instance of the class and specifies the that can be inserted into the serialized array.

  The of the object to serialize.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  This overload sets the and the properties.

  Use this overload if you want the name of the generated XML element to differ from the member's identifier.

  An XML document that includes namespaces can contain more than one version of an element name. For details, see the property.

  Initializes a new instance of the class and specifies the name of the XML element generated in the XML document and the that can be inserted into the generated XML document.

  The name of the XML element.
  The of the object to serialize.
- 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 objects, and apply an with the property 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. However, 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 then passing it as an XML attribute.

  For more information about XML Schema data types, see the World Wide Web Consortium (www.w3.org) document "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 data type of the generated XML element.

- 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 identically named members. For details about 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 name is qualified, based on the World Wide Web Consortium (www.w3.org) 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 value, XmlSchemaForm.None, instructs the to check the schema for the XML document to determine whether the namespace is qualified. For elements, the checks the value of the schema-element attribute elementFormDefault. For attributes, it checks the value of the schema-element attribute attributeFormDefault. For example, the following XML Schema indicates that the Name element is qualified, while the Number element is unqualified.

  `<schema elementFormDefault="qualified" attributeFormDefault="unqualified"> <element name="Name"/> <attribute name="Number"/> </schema>`

  Gets or sets a value that indicates whether the name of the generated XML 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 titled "XML Schema Part 1: Structures."

  If the property is 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.

  You cannot apply the property to a member typed as a value type because a value type cannot contain null.

  Gets or sets a value that indicates whether the must serialize a member as an empty XML 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 to use in the XML document and associated prefixes, you must create an that contains all the prefix and namespace pairs. The namespace you set for each must be contained in the . When the generates the document, it correctly prefixes the element name for each array item.

  Gets or sets the namespace of the generated XML element.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 To be added: an object of type 'int'

  An XML document can contain hierarchies of XML elements. To represent such a hierarchy, an array of arrays is used. In such an array, each index represents a level in the hierarchy. Therefore, the property is only used when applying an to a field that returns an array of arrays.

  When applying the attribute, specify which hierarchy level the attribute affects by setting the . The first index always has the value of 0; therefore it is optional to set its --an without a value is applied to the first array index. Only the subsequent objects require values specified (as 1, 2, 3, and so forth).

  Gets or sets the level in a hierarchy of XML elements that the affects.

- 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 an overridden type for a public field or public read/write property value.

  If a field or property returns an array of type , apply multiple instances of the to the field or property. For each instance, set the property to a type of object that can be inserted into the array.

  If an array contains only primitive types, you do not need to apply the . By default, the generates a series of elements, each with the same element name, for each value, but the type of each element is set to the XML Schema data type. For example, the following code:

  `' Visual Basic code Public Class Arrays Public XSDTypes ()As Object= New Object(){"one", 2, 3.0} End Class // C# code public class MyArray{ // No XmlArrayItemAttribute is applied. public object[] XSDTypes= new object[]{"one", 2, 3.2}; }`

  results in this XML:

  `<?xml version="1.0" encoding="utf-8"?> <Arrays xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <XSDTypes> <Object xsi:type="xsd:string">one</Object> <Object xsi:type="xsd:int">2</Object> <Object xsi:type="xsd:double">3</Object> </XSDTypes> </Arrays>`

  However, if you specify the property for each primitive type, the element name for each value is generated using the .NET type name. For example this code:

  `' Visual Basic code Public Class Arrays <XmlArrayItem(GetType(String)), _ XmlArrayItem(GetType(Integer)), _ XmlArrayItem(GetType(Double))> _ Public PrimitiveTypes () As Object = New Object(){"one", 2, 3.0} End Class // C# code public class Arrays{ [XmlArrayItem(typeof(string))] [XmlArrayItem(typeof(int))] [XmlArrayItem(typeof(double))] public object [] PrimitiveTypes = new object[]{"one", 2, 3.0}; }`

  results in this XML:

  `<?xml version="1.0" encoding="utf-8"?> <Arrays xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <PrimitiveTypes> <string>one</string> <int>2</int> <double>3</double> </PrimitiveTypes> </Arrays>`

  Gets or sets the type allowed in an array.