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.

Inheritance Hierarchy


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


<AttributeUsageAttribute(AttributeTargets.Field Or AttributeTargets.Parameter Or AttributeTargets.Property Or AttributeTargets.ReturnValue, AllowMultiple := False)> _
Public Class XmlAnyAttributeAttribute _
    Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Field|AttributeTargets.Parameter|AttributeTargets.Property|AttributeTargets.ReturnValue, AllowMultiple = false)]
public class XmlAnyAttributeAttribute : Attribute

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.


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" 
 GroupType = 'Technical' GroupNumber = '42' GroupBase = 'Red'>

Version Information

Windows Phone OS

Supported in: 8.1, 8.0

Thread Safety

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

See Also


System.Xml.Serialization Namespace




Other Resources