Skip to main content

Definition

Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml.Serialization Inheritance: System.Attribute

Syntax

Summary

Specifies the name and namespace of the document element that a type is serialized as. This class cannot be inherited.

Usage

Apply [XmlRoot] to a class, struct, or interface to name the document element that is written when a value of that type is the root of the document. Without it, the document element is the type name, converted by the element naming policy.
The code produces the following output:
View the complete sample on GitHub Set Namespace to put the document element in an XML namespace. See Namespaces.

Considerations

  • The name is used exactly as written. A naming policy doesn’t convert it.
  • When reading, the document element must have this name, or the serializer throws an XmlException. The name is matched with case unless PropertyNameCaseInsensitive is set, which ignores the case of ASCII letters for the document element as it does for members.
  • The attribute names the type as a document element. When the type is the type of a member of another object, the element is named after that member.
  • When Namespace is null, XmlSerializerOptions.DefaultNamespace is used.
  • A null reference at the root is always written as the document element marked xsi:nil="true".

Constructors

.ctor

Initializes a new instance of the XmlRootAttribute class that uses the name of the type as the document element name.

Syntax

.ctor

Initializes a new instance of the XmlRootAttribute class with the specified document element name.

Syntax

Parameters

Exceptions

.ctor Inherited

Inherited from System.Attribute

Syntax

.ctor Inherited

Inherited from object

Syntax

Properties

ElementName

Gets or sets the local name of the document element.

Syntax

Property Value

Type: string? The local name of the document element. If the value is null or empty, the name of the type is used, converted by the element naming policy. The default is null.

Namespace

Gets or sets the namespace URI of the document element.

Syntax

Property Value

Type: string? The namespace URI of the document element. If the value is null, XmlSerializerOptions.DefaultNamespace is used. The default is null.

TypeId Inherited Virtual

Inherited from System.Attribute

Syntax

Property Value

Type: object

Methods

Equals Override

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

Equals Inherited Virtual

Inherited from object

Syntax

Parameters

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetHashCode Override

Inherited from System.Attribute

Syntax

Returns

Type: int

GetHashCode Inherited Virtual

Inherited from object

Syntax

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

Returns

Type: System.Type

IsDefaultAttribute Inherited Virtual

Inherited from System.Attribute

Syntax

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

Match Inherited Virtual

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

MemberwiseClone Inherited

Inherited from object

Syntax

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

ToString Inherited Virtual

Inherited from object

Syntax

Returns

Type: string?
  • CloudNimble.Text.Xml.XmlSerializer
  • CloudNimble.Text.Xml.XmlSerializerOptions
  • CloudNimble.Text.Xml.XmlNamingPolicy
  • CloudNimble.Text.Xml.Serialization.XmlPropertyNameAttribute
  • CloudNimble.Text.Xml.Serialization.XmlElementAttribute