Export (0) Print
Expand All

XmlArrayAttribute Class

Specifies that the XmlSerializer must serialize a particular class member as an array of XML elements.

System.Object
  System.Attribute
    System.Xml.Serialization.XmlArrayAttribute

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

'Declaration
<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Field Or AttributeTargets.Parameter Or AttributeTargets.ReturnValue, AllowMultiple := False)> _
Public Class XmlArrayAttribute _
	Inherits Attribute

The XmlArrayAttribute type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360XmlArrayAttributeInitializes a new instance of the XmlArrayAttribute class.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360XmlArrayAttribute(String)Initializes a new instance of the XmlArrayAttribute class and specifies the XML element name generated in the XML document instance.
Top

  NameDescription
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360ElementNameGets or sets the XML element name given to the serialized array.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360FormGets or sets a value that indicates whether the XML element name generated by the XmlSerializer is qualified or unqualified.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360IsNullableGets or sets a value that indicates whether the XmlSerializer must serialize a member as an empty XML element with the xsi:nil attribute set to true.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360NamespaceGets or sets the namespace of the XML element.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360OrderGets or sets the explicit order in which the elements are serialized or deserialized.
Top

  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360EqualsInfrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360FinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetHashCodeReturns the hash code for this instance. (Inherited from Attribute.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360MatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The XmlArrayAttribute belongs to a family of attributes that controls how the XmlSerializer serializes or deserializes an object.

You can apply the XmlArrayAttribute to a public field or read/write property that returns an array of objects, a collection, or any class that implements the IEnumerable interface.

When you apply the XmlArrayAttribute to a class member, the Serialize method of the XmlSerializer class generates a nested sequence of XML elements from that member. An XML schema document (an .xsd file) indicates such an array as a complexType. For example, if the class to be serialized represents a purchase order, you can generate an array of purchased items by applying the XmlArrayAttribute to a public field that returns an array of objects that represent order items.

If no attributes are applied to a public field or property that returns an array of complex or primitive type objects, the XmlSerializer generates a nested sequence of XML elements by default. To more precisely control what XML elements are generated, apply an XmlArrayItemAttribute and an XmlArrayAttribute to the field or property. For example, by default, the name of the generated XML element is derived from the member identifier. You can change the name of the generated XML element by setting the ElementName property.

If you serialize an array that contains items of a specific type and all the classes derived from that type, you must use the XmlArrayItemAttribute to declare each of the types.

NoteNote:

You can use XmlArray in your code instead of the longer XmlArrayAttribute.

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

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft