XmlAnyAttributeAttribute Class
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Specifies that the member (a field that returns an array of XmlAttribute objects) can contain any XML attributes.
Assembly: System.Xml.Serialization (in System.Xml.Serialization.dll)
The XmlAnyAttributeAttribute type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | XmlAnyAttributeAttribute | Constructs a new instance of the XmlAnyAttributeAttribute class. |
| Name | Description | |
|---|---|---|
![]() | 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.) |
Use the XmlAnyAttributeAttribute to contain arbitrary data (as XML attributes) that is sent as part of an XML document, such as, metadata sent as part of the document.
Apply the XmlAnyAttributeAttribute to a field that returns an array of XmlAttribute or XmlNode objects. When the Deserialize method of the XmlSerializer class is called, all XML attributes that do not have a corresponding member in the class being deserialized are collected in the array. After deserialization, you can iterate through the collection of XmlAttribute items to process the data.
The UnknownNode() and UnknownAttribute() events of the XmlSerializer do not occur if you apply the XmlAnyAttributeAttribute to a member of a class.
Note: |
|---|
You can use the word XmlAnyAttribute in your code instead of the longer XmlAnyAttributeAttribute. |
For more information about using attributes, see [30386922-1e00-4602-9ebf-526b271a8b87].
The following example collects all unknown attributes into an array of XmlAttribute objects. To try the example, create a file named UnknownAttributes.xml that contains the following XML:
<?xml version="1.0" encoding="utf-8"?> <Group xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" GroupType = 'Technical' GroupNumber = '42' GroupBase = 'Red'> <GroupName>MyGroup</GroupName> </Group>


Note: