XmlAttributes Class

 

Represents a collection of attribute objects that control how the XmlSerializer serializes and deserializes an object.

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

System.Object
  System.Xml.Serialization.XmlAttributes

type XmlAttributes = class end

NameDescription
System_CAPS_pubmethodXmlAttributes()

Initializes a new instance of the XmlAttributes class.

System_CAPS_pubmethodXmlAttributes(ICustomAttributeProvider)

This API supports the product infrastructure and is not intended to be used directly from your code. Initializes a new instance of the XmlAttributes class and customizes how the XmlSerializer serializes and deserializes an object.

NameDescription
System_CAPS_pubpropertyXmlAnyAttribute

Gets or sets the XmlAnyAttributeAttribute to override.

System_CAPS_pubpropertyXmlAnyElements

Gets the collection of XmlAnyElementAttribute objects to override.

System_CAPS_pubpropertyXmlArray

Gets or sets an object that specifies how the XmlSerializer serializes a public field or read/write property that returns an array.

System_CAPS_pubpropertyXmlArrayItems

Gets or sets a collection of objects that specify how the XmlSerializer serializes items inserted into an array returned by a public field or read/write property.

System_CAPS_pubpropertyXmlAttribute

Gets or sets an object that specifies how the XmlSerializer serializes a public field or public read/write property as an XML attribute.

System_CAPS_pubpropertyXmlChoiceIdentifier

Gets or sets an object that allows you to distinguish between a set of choices.

System_CAPS_pubpropertyXmlDefaultValue

Gets or sets the default value of an XML element or attribute.

System_CAPS_pubpropertyXmlElements

Gets a collection of objects that specify how the XmlSerializer serializes a public field or read/write property as an XML element.

System_CAPS_pubpropertyXmlEnum

Gets or sets an object that specifies how the XmlSerializer serializes an enumeration member.

System_CAPS_pubpropertyXmlIgnore

Gets or sets a value that specifies whether or not the XmlSerializer serializes a public field or public read/write property.

System_CAPS_pubpropertyXmlns

Gets or sets a value that specifies whether to keep all namespace declarations when an object containing a member that returns an XmlSerializerNamespaces object is overridden.

System_CAPS_pubpropertyXmlRoot

Gets or sets an object that specifies how the XmlSerializer serializes a class as an XML root element.

System_CAPS_pubpropertyXmlText

Gets or sets an object that instructs the XmlSerializer to serialize a public field or public read/write property as XML text.

System_CAPS_pubpropertyXmlType

Gets or sets an object that specifies how the XmlSerializer serializes a class to which the XmlTypeAttribute has been applied.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

Creating the XmlAttributes is part of a process that overrides the default way the XmlSerializer serializes class instances. For example, suppose you want to serialize an object that is created from a DLL which has an inaccessible source. By using the XmlAttributeOverrides, you can augment or otherwise control how the object is serialized.

The members of the XmlAttributes class correspond directly to a family of attribute classes that control serialization. For example, the XmlText property must be set to an XmlTextAttribute, which allows you to override serialization of a field or property by instructing the XmlSerializer to serialize the property value as XML text. For a complete list of attributes that control serialization, see the XmlSerializer.

For more details on using the XmlAttributeOverrides with the XmlAttributes class, see How to: Specify an Alternate Element Name for an XML Stream.

The following example serializes an instance of a class named Orchestra, which contains a single field named Instruments that returns an array of Instrument objects. A second class named Brass inherits from the Instrument class. The example creates an XmlAttributes object to override the Instrument field--allowing the field to accept Brass objects--and adds the XmlAttributes object to an instance of the XmlAttributeOverrides class.

No code example is currently available or this language may not be supported.

Universal Windows Platform
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.

Return to top
Show: