Skip to main content

Definition

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

Syntax

Summary

Specifies how XmlSerializer handles XML elements and attributes that cannot be mapped to a specific .NET member when deserializing object types.

Usage

XmlUnmappedMemberHandling says what the serializer does, when reading, with an element or attribute that no member of the target type maps to. Set it through XmlSerializerOptions.UnmappedMemberHandling. It is the counterpart of JsonUnmappedMemberHandling.
The code produces the following output:
View the complete sample on GitHub

Remarks

When the type has a member marked with XmlExtensionDataAttribute, or a member marked with XmlMixedAttribute for elements, that member captures the unmapped content and neither value applies.

Considerations

  • The setting is on the options and applies to every type in the object graph. There is no attribute that sets it for one type.
  • Namespace declarations, xsi:nil, xsi:type, and the attributes the serializer itself writes for polymorphism and preserved references are never treated as unmapped.
  • A member marked [XmlIgnore] isn’t mapped, so with Disallow an element for it is an error.
  • When the type has an [XmlExtensionData] member, unmapped elements and attributes are collected there, and Disallow doesn’t reject them.
  • Names are matched with case unless PropertyNameCaseInsensitive is true, so with Disallow an element that differs from a member only by case is an error.
  • XmlSerializerOptions.Strict sets Disallow.

Values

  • CloudNimble.Text.Xml.XmlSerializerOptions
  • CloudNimble.Text.Xml.XmlSerializerDefaults
  • CloudNimble.Text.Xml.XmlException
  • CloudNimble.Text.Xml.Serialization.XmlExtensionDataAttribute
  • CloudNimble.Text.Xml.Serialization.XmlIgnoreAttribute
  • CloudNimble.Text.Xml.Serialization.XmlRequiredAttribute