Export (0) Print
Expand All

XmlArrayItemAttribute.Form Property

Gets or sets a value that indicates whether the name of the generated XML element 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 XmlSchemaForm.None.

ExceptionCondition
Exception

The Form property is set to XmlSchemaForm.Unqualified and a Namespace value is specified.

The Form property determines whether an XML element name is qualified, based on the World Wide Web Consortium (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 value, XmlSchemaForm.None, instructs the XmlSerializer to check the schema for the XML document to determine whether the namespace is qualified. For elements, the XmlSerializer checks the value of the schema-element attribute elementFormDefault. For attributes, it checks the value of the schema-element attribute attributeFormDefault. For example, the following XML Schema indicates that the Name element is qualified, while the Number element is unqualified.

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

The following example sets the Form property for the Vehicle class to XmlSchemaForm.Unqualified, and the Form property for the Car class to XmlSchemaForm.Qualified.

public class Transportation
{  
   [XmlArray("Vehicles")]
   // Specifies the Form property value.
   [XmlArrayItem(typeof(Vehicle), 
   Form = XmlSchemaForm.Unqualified), 
   XmlArrayItem(typeof(Car), 
   Form = XmlSchemaForm.Qualified)]
   public Vehicle[] MyVehicles;
}

public class Vehicle
{
   public string id;
}

public class Car:Vehicle
{
   public string Maker;
}

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft