Assembly: System.Xml (in System.Xml.dll)
Thetype exposes the following members.
|XmlAttributeAttribute||Initializes a new instance of the class.|
|XmlAttributeAttribute(String)||Initializes a new instance of the class and specifies the name of the generated XML attribute.|
|XmlAttributeAttribute(Type)||Initializes a new instance of the class.|
|XmlAttributeAttribute(String, Type)||Initializes a new instance of the class.|
|AttributeName||Gets or sets the name of the XML attribute.|
|DataType||Gets or sets the XSD data type of the XML attribute generated by the XmlSerializer.|
|Form||Gets or sets a value that indicates whether the XML attribute name generated by the XmlSerializer is qualified.|
|Namespace||Gets or sets the XML namespace of the XML attribute.|
|Type||Gets or sets the complex type of the XML attribute.|
|Equals||Infrastructure. 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 the Object is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Returns the hash code for this instance. (Inherited from Attribute.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|Match||When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
The belongs to a family of attributes that controls how the XmlSerializer serializes or deserializes an object.
When applied to a public field or property, the informs the XmlSerializer to serialize the member as an XML attribute. By default, the XmlSerializer serializes public fields and properties as XML elements.
You can assign the only to public fields or public properties that return a value (or array of values) that can be mapped to one of the XML Schema definition (XSD) language simple types (including all built-in data types derived from the XSD anySimpleType type). The possible types include any that can be mapped to the XSD simple types, including Guid, Char, and enumerations. See the DataType property for a list of XSD types and how they are mapped to .NET data types.
There are two special attributes that can be set with the : the xml:lang (specifies language) and xml:space (specifies how to handle white space) attributes. These attributes are intended to convey information that is relevant only to an application that is processing the XML. Examples of setting these are shown in the following code.
[XmlAttribute("xml:lang")] public string Lang; // Set this to 'default' or 'preserve'. [XmlAttribute("space", Namespace = "http://www.w3.org/XML/1998/namespace")] public string Space [Visual Basic] <XmlAttribute("xml:lang")> _ Public Lang As String ' Set this to 'default' or 'preserve'. <XmlAttribute("space", _ Namespace:= "http://www.w3.org/XML/1998/namespace")> _ Public Space As String
You can use the word XmlAttribute in your code instead of the longer .