XmlArrayAttribute Class
Specifies that the XmlSerializer must serialize a particular class member as an array of XML elements.
Assembly: System.Xml (in System.Xml.dll)
| Name | Description | |
|---|---|---|
![]() | XmlArrayAttribute() | Initializes a new instance of the XmlArrayAttribute class. |
![]() | XmlArrayAttribute(String) | Initializes a new instance of the XmlArrayAttribute class and specifies the XML element name generated in the XML document instance. |
| Name | Description | |
|---|---|---|
![]() | ElementName | Gets or sets the XML element name given to the serialized array. |
![]() | Form | Gets or sets a value that indicates whether the XML element name generated by the XmlSerializer is qualified or unqualified. |
![]() | IsNullable | Gets or sets a value that indicates whether the XmlSerializer must serialize a member as an empty XML tag with the xsi:nil attribute set to true. |
![]() | Namespace | Gets or sets the namespace of the XML element. |
![]() | Order | Gets or sets the explicit order in which the elements are serialized or deserialized. |
![]() | TypeId |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | 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.) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetHashCode() | Returns the hash code for this instance.(Inherited from Attribute.) |
![]() | GetType() | |
![]() | IsDefaultAttribute() | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.(Inherited from Attribute.) |
![]() | Match(Object) | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.(Inherited from Attribute.) |
![]() | MemberwiseClone() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | _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.) |
![]() ![]() | _Attribute.GetTypeInfoCount(UInt32) | 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.) |
The XmlArrayAttribute belongs to a family of attributes that controls how the XmlSerializer serializes or deserializes an object. For a complete list of similar attributes, see Attributes That Control XML Serialization.
You can apply the XmlArrayAttribute to a public field or read/write property that returns an array of objects. You can also apply it to collections and fields that return an ArrayList or any field that returns an object 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.
Note |
|---|
You can use XmlArray in your code instead of the longer XmlArrayAttribute. |
For more information about using attributes, see Extending Metadata Using Attributes.
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
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.
XmlArray
XmlArrayItemAttribute
XmlAttributeOverrides
XmlAttributes
XmlAttributes
System.Xml.Serialization Namespace
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)





