Export (0) Print
Expand All

XmlAttributes Class

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

System.Object
  System.Xml.Serialization.XmlAttributes

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

type XmlAttributes =  class end

The XmlAttributes type exposes the following members.

  NameDescription
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlAttributes()Initializes a new instance of the XmlAttributes class.
Public methodXmlAttributes(ICustomAttributeProvider)Infrastructure. Initializes a new instance of the XmlAttributes class and customizes how the XmlSerializer serializes and deserializes an object.
Top

  NameDescription
Public propertySupported by the XNA FrameworkSupported in .NET for Windows Store appsXmlAnyAttributeGets or sets the XmlAnyAttributeAttribute to override.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlAnyElementsGets the collection of XmlAnyElementAttribute objects to override.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlArrayGets or sets an object that specifies how the XmlSerializer serializes a public field or read/write property that returns an array.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlArrayItemsGets 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.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlAttributeGets or sets an object that specifies how the XmlSerializer serializes a public field or public read/write property as an XML attribute.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlChoiceIdentifierGets or sets an object that allows you to distinguish between a set of choices.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlDefaultValueGets or sets the default value of an XML element or attribute.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlElementsGets a collection of objects that specify how the XmlSerializer serializes a public field or read/write property as an XML element.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlEnumGets or sets an object that specifies how the XmlSerializer serializes an enumeration member.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlIgnoreGets or sets a value that specifies whether or not the XmlSerializer serializes a public field or public read/write property.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlnsGets 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.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlRootGets or sets an object that specifies how the XmlSerializer serializes a class as an XML root element.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlTextGets or sets an object that instructs the XmlSerializer to serialize a public field or public read/write property as XML text.
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsXmlTypeGets or sets an object that specifies how the XmlSerializer serializes a class to which the XmlTypeAttribute has been applied.
Top

  NameDescription
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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