Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

XmlAttributeAttribute.Form Property

Gets or sets a value that indicates whether the XML attribute name generated by the XmlSerializer is qualified.

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

public XmlSchemaForm Form { get; set; }

Property Value

Type: System.Xml.Schema.XmlSchemaForm
One of the XmlSchemaForm values. The default is XmlForm.None.

The Form property determines whether an XML element is qualified or unqualified. The Form property conforms to the 1999 http://www.w3.org specification Namespaces in XML.

If the Namespace property is set to any value, attempting to set the Form property to XmlSchemaForm.Unqualified throws an exception.

The default setting, XmlSchemaForm.None, instructs the XmlSerializer to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the XmlSerializer uses the elementFormDefault and attributeFormDefault values to determine whether an element or attribute is qualified. The following XML code shows a schema:

 <schema elementFormDefault="qualified" 
 attributeFormDefault="unqualified"... >
    <element name="Name"/>
    <attribute name="Number"/>
 </schema>

When the XmlSerializer reads the schema, the Form value for both the Name and Number is XmlSchemaForm.None, but the Name element is qualified, while the Number element is unqualified.

The following example applies the XmlAttributeAttribute to two fields contained in a class.

public class Vehicle
{
   [XmlAttribute(Form = XmlSchemaForm.Qualified)]
   public string Maker;

   [XmlAttribute(Form = XmlSchemaForm.Unqualified)]
   public string ModelID;
}
public __gc class Vehicle
{
public:
   [XmlAttributeAttribute(Form = XmlSchemaForm::Qualified)]
   String* Maker;

public:
   [XmlAttributeAttribute(Form = XmlSchemaForm::Unqualified)]
   String* ModelID;
};

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0

XNA Framework

Supported in: 3.0, 2.0, 1.0

Community Additions

Show:
© 2014 Microsoft