Item Property (Type)
Collapse the table of content
Expand the table of content

XmlAttributeOverrides.Item Property (Type)

Gets the object associated with the specified, base-class, type.

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

public XmlAttributes this [
	Type type
] { get; }
/** @property */
public XmlAttributes get_Item (Type type)

Not applicable.



The base class Type that is associated with the collection of attributes you want to retrieve.

Property Value

An XmlAttributes that represents the collection of overriding attributes.

Use this overload to return an XmlAttributes object that contains attributes for an XmlRootAttribute or XmlTypeAttribute object.

If the XmlAttributes object contains objects that override an XmlArrayAttribute, XmlArrayItemAttribute, XmlElementAttribute, XmlEnumAttribute, or XmlAttributeAttribute, you must use the overload that specifies the overridden member as well as the type.

The following example creates an XmlAttributeOverrides object, an XmlAttributes object, and an XmlRootAttribute object. The example assigns the XmlRootAttribute to the XmlRoot property of the XmlAttributes object, and adds the XmlAttributes object to the XmlAttributeOverrides object. Lastly, the example gets the XmlAttributes object by passing the Type of the serialized class to the XmlAttributeOverrides object. In this example, the Type is Group.

// This is the class that will be serialized.
public class Group
   public string GroupName;
   public int GroupCode;

public class Sample
public XmlSerializer CreateOverrider()
   // Create an XmlSerializer with overriding attributes.
   XmlAttributes attrs = new XmlAttributes();
   XmlAttributeOverrides xOver = new XmlAttributeOverrides();
   XmlRootAttribute xRoot = new XmlRootAttribute();
   // Set a new Namespace and ElementName for the root element.
   xRoot.Namespace = "";
   xRoot.ElementName = "NewGroup";
   attrs.XmlRoot = xRoot;
   xOver.Add(typeof(Group), attrs);

   // Get the XmlAttributes object, based on the type.
   XmlAttributes tempAttrs;
   tempAttrs = xOver[typeof(Group)];

   // Print the Namespace and ElementName of the root.

   XmlSerializer xSer = new XmlSerializer(typeof(Group), xOver);
   return xSer;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0

Community Additions

© 2016 Microsoft