Definition
Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml.Serialization Inheritance: CloudNimble.Text.Xml.Serialization.XmlElementAttributeSyntax
Summary
Specifies that a member is serialized as a child element of type T. This class cannot be inherited.Usage
Apply[XmlElement] to a property or field to say that it is a child element and, optionally, to set the element’s name, namespace, or order. A member is an element by default, so you need the attribute in three cases:
- To name the element, as an alternative to
[XmlPropertyName]. - To keep one member as an element when
XmlSerializerOptions.DefaultPropertyMappingisXmlPropertyMapping.Attribute. - To set
NamespaceorOrder.
[XmlArray], the name applies to each repeated item:
Type Parameters
T- The type that is serialized with the element name.
Considerations
[XmlPropertyName]on the same member takes precedence overElementName, and[XmlPropertyOrder]takes precedence overOrder.- A name set here isn’t converted by a naming policy.
Orderfollows the rules of[XmlPropertyOrder]: values of zero or more are written first in ascending order, and a negative value, the default, means the order isn’t set.- A member can’t be both an element and something else.
[XmlElement]together with[XmlAttribute],[XmlText], or[XmlCData]throws aNotSupportedExceptionthe first time the type is used. - Several
[XmlElement<T>]on one member make a choice of elements: each element name stands for a type, a value is written under the element of its type, and an element is read as the type of its name. On a collection, each item is written under the element of its own type. A value of the member’s own type is written under the member’s name. When two elements hold the same type, declare the member asXmlNamedValue, or a collection of it, so each value carries the name of its element. See Polymorphism. - A member can have one
[XmlElement]without a type argument. A second one, or one next to[XmlElement<T>], throws aNotSupportedExceptionthe first time the type is used.
Constructors
.ctor
Initializes a new instance of theXmlElementAttribute1` class that uses the default element name:
the member name, or the element name of T when the member has more than one of these attributes.
Syntax
.ctor
Initializes a new instance of theXmlElementAttribute1` class with the specified element name.
Syntax
Parameters
Exceptions
.ctor
Initializes a new instance of theXmlElementAttribute1` class with the specified element name and namespace.
Syntax
Parameters
Exceptions
.ctor Inherited
Inherited from
CloudNimble.Text.Xml.Serialization.XmlElementAttributeSyntax
.ctor Inherited
Inherited from
CloudNimble.Text.Xml.Serialization.XmlElementAttributeSyntax
Parameters
Exceptions
.ctor Inherited
Inherited from
CloudNimble.Text.Xml.Serialization.XmlElementAttributeSyntax
Parameters
Exceptions
.ctor Inherited
Inherited from
System.AttributeSyntax
.ctor Inherited
Inherited from
objectSyntax
Properties
ElementName Inherited
Inherited from
CloudNimble.Text.Xml.Serialization.XmlElementAttributeSyntax
Property Value
Type:string?
The local name of the element. If the value is null or empty, the member name is used,
converted by the element naming policy. The default is null.
Remarks
An XmlPropertyNameAttribute on the same member takes precedence over this property.IsNullable Inherited
Inherited from
CloudNimble.Text.Xml.Serialization.XmlElementAttributeSyntax
Property Value
Type:bool
true if the member is nillable; otherwise, false. The default is false.
Remarks
A member whose type is a reference type, a Nullable`1, or a collection is nillable whatever this value is.Namespace Inherited
Inherited from
CloudNimble.Text.Xml.Serialization.XmlElementAttributeSyntax
Property Value
Type:string?
The namespace URI of the element. If the value is null, the element is written with an unqualified name,
so it is in the default namespace that is in scope. An empty string puts the element in no namespace.
The default is null.
Remarks
An element in no namespace is written withxmlns="" where a default namespace is in scope, and
only an element in no namespace is read as the member.
Order Inherited
Inherited from
CloudNimble.Text.Xml.Serialization.XmlElementAttributeSyntax
Property Value
Type:int
The order of the element. Lower values are written first. A negative value means the order is not set. The default is -1.
Remarks
An XmlPropertyOrderAttribute on the same member takes precedence over this property.Type Override
Syntax
Property Value
Type:System.Type
Type Inherited Virtual
Inherited from
CloudNimble.Text.Xml.Serialization.XmlElementAttributeSyntax
Property Value
Type:System.Type?
The type that the element name applies to, or null if the type of the member is used.
TypeId Inherited Virtual
Inherited from
System.AttributeSyntax
Property Value
Type:object
Methods
Equals Override
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetHashCode Override
Inherited from
System.AttributeSyntax
Returns
Type:int
GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
IsDefaultAttribute Inherited Virtual
Inherited from
System.AttributeSyntax
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
Match Inherited Virtual
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
ToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
Related APIs
- CloudNimble.Text.Xml.Serialization.XmlPropertyNameAttribute
- CloudNimble.Text.Xml.Serialization.XmlPropertyOrderAttribute
- CloudNimble.Text.Xml.Serialization.XmlAttributeAttribute
- CloudNimble.Text.Xml.Serialization.XmlTextAttribute
- CloudNimble.Text.Xml.Serialization.XmlArrayAttribute
- CloudNimble.Text.Xml.XmlPropertyMapping