XmlElementAttribute.Form Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a value that indicates whether the element is qualified.
public:
property System::Xml::Schema::XmlSchemaForm Form { System::Xml::Schema::XmlSchemaForm get(); void set(System::Xml::Schema::XmlSchemaForm value); };
public System.Xml.Schema.XmlSchemaForm Form { get; set; }
member this.Form : System.Xml.Schema.XmlSchemaForm with get, set
Public Property Form As XmlSchemaForm
One of the XmlSchemaForm values. The default is None.
The following example sets the Form property to XmlSchemaForm.Unqualified
.
public ref class MyClass
{
public:
[XmlElement(Form=XmlSchemaForm::Unqualified)]
String^ ClassName;
};
public class MyClass
{
[XmlElement(Form = XmlSchemaForm.Unqualified)]
public string ClassName;
}
Public Class MyClass1
<XmlElement(Form := XmlSchemaForm.Unqualified)> _
Public ClassName As String
End Class
The Form property determines whether an XML element is qualified or unqualified. The Form property conforms to the World Wide Web Consortium 1999 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.
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
UWP | 10.0 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: