This documentation is archived and is not being maintained.

XmlRootAttribute.Namespace Property

Gets or sets the namespace for the XML root element.

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

Property Value

The namespace for the XML element.


The Namespace property conforms to the World Wide Web Consortium ( 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.


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

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

[XmlRoot(Namespace = "")]
public class Group
   // Insert the members of the Group class.

[XmlRoot(Namespace = S"")]
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.


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