System.Xml.Serialization.XmlAnyElementAttribute.Name Property

Gets or sets the XML element name.

Syntax

public string Name { get; set; }

Value

Documentation for this section has not yet been entered.

Remarks

If you specify a XmlAnyElementAttribute.Name property value when applying the attribute, all System.Xml.XmlElement or System.Xml.XmlNode objects inserted into the array must have the same element name and default namespace, or an exception is thrown. If you set the XmlAnyElementAttribute.Namespace property value, you must set the XmlAnyElementAttribute.Name property as well, and the System.Xml.XmlElement or System.Xml.XmlNode objects must also have the same name and namespace values. If no XmlAnyElementAttribute.Name value is specified, the System.Xml.XmlElement or System.Xml.XmlNode objects can have any element name.

When you call the XmlSerializer.Deserialize(System.IO.Stream) method of the System.Xml.Serialization.XmlSerializer class, all attributes that do not have a corresponding member in the object being deserialized are collected in the array. If you specify a XmlAnyElementAttribute.Name value, the array contains only XML elements with that name. If you do not specify a XmlAnyElementAttribute.Name value, the array contains all elements that have no corresponding member in the class. If a class contains more than one field to which the attribute is applied, use the XmlAnyElementAttribute.Name and XmlAnyElementAttribute.Namespace properties to differentiate between the contents of the arrays. If such a class (with multiple fields) also contains one field that has no differentiating property values set (that is, XmlAnyElementAttribute.Name and XmlAnyElementAttribute.Namespace) during deserialization, the array contains any XML elements that are not already contained in the other arrays. If you add more than one field that does not have a differentiating XmlAnyElementAttribute.Name or XmlAnyElementAttribute.Namespace value set, the last field in the class contains all unknown elements that are not already contained in the other arrays, and any other fields are set to null.

You can apply multiple instances of the System.Xml.Serialization.XmlAnyElementAttribute to a class member, but each instance must have a distinct XmlAnyElementAttribute.Name property value. Or, if the same XmlAnyElementAttribute.Name property is set for each instance, a distinct XmlAnyElementAttribute.Namespace property value must be set for each instance.

Requirements

Namespace: System.Xml.Serialization
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0