Export (0) Print
Expand All

XmlRootAttribute.Namespace Property

Gets or sets the namespace for the XML root element.

[Visual Basic]
Public Property Namespace As String
[C#]
public string Namespace {get; set;}
[C++]
public: __property String* get_Namespace();
public: __property void set_Namespace(String*);
[JScript]
public function get Namespace() : String;
public function set Namespace(String);

Property Value

The namespace for the XML element.

Remarks

The Namespace property conforms to the World Wide Web Consortium (www.w3.org) specification named Namespaces in XML.

To create prefixed namespaces in the XML document, create an XmlSerializerNamespaces object that contains all the prefix-namespace pairs. The namespace you set for each XmlArrayAttribute must be contained in the XmlSerializerNamespaces object. When the XmlSerializer generates the document, it correctly prefixes the element name for each array item.

Example

[Visual Basic, C#, C++] The following example applies the XmlRootAttribute to a class and sets the Namespace property.

[Visual Basic] 
<XmlRoot(Namespace := "http://www.cpandl.com")> _
Public Class Group
    ' Insert the members of the Group class.
End Class

[C#] 
[XmlRoot(Namespace = "http://www.cpandl.com")]
public class Group
{
   // Insert the members of the Group class.
}
   

[C++] 
[XmlRoot(Namespace = S"http://www.cpandl.com")]
public __gc class Group
{
   // Insert the members of the Group class.
};
   

[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

XmlRootAttribute Class | XmlRootAttribute Members | System.Xml.Serialization Namespace | XmlAttributeOverrides | XmlAttributes | XmlRoot

Show:
© 2015 Microsoft