Windows apps
Collapse the table of content
Expand the table of content
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 indicating whether the XML attribute name generated by the XmlSerializer is qualified.

[Visual Basic]
Public Property Form As XmlSchemaForm
[C#]
public XmlSchemaForm Form {get; set;}
[C++]
public: __property XmlSchemaForm get_Form();
public: __property void set_Form(XmlSchemaForm);
[JScript]
public function get Form() : XmlSchemaForm;
public function set Form(XmlSchemaForm);

Property Value

One of the XmlSchemaForm values. The default is XmlForm.None.

Remarks

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 XML code below 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 will be XmlSchemaForm.None, but the Name element will be qualified, while the Number element will be unqualified.

Example

[Visual Basic, C#, C++] The following example applies the XmlAttributeAttribute to two fields contained in a class.

[Visual Basic] 
Public Class Vehicle
    <XmlAttribute(Form := XmlSchemaForm.Qualified)> _
    Public Maker As String    

    <XmlAttribute(Form := XmlSchemaForm.Unqualified)> _
    Public ModelID As String
End Class


[C#] 
public class Vehicle
{
   [XmlAttribute(Form = XmlSchemaForm.Qualified)]
   public string Maker;
 
   [XmlAttribute(Form = XmlSchemaForm.Unqualified)]
   public string ModelID;
}


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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

XmlAttributeAttribute Class | XmlAttributeAttribute Members | System.Xml.Serialization Namespace

Show:
© 2017 Microsoft