Definition
Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml Inheritance: System.EnumSyntax
Summary
Specifies how a property or field without a mapping attribute is mapped: as a child element or as an XML attribute.Usage
XmlPropertyMapping says what a member becomes in XML when it has no [XmlElement], [XmlAttribute], or [XmlText] attribute. Set it through XmlSerializerOptions.DefaultPropertyMapping.
Use
Attribute for formats that put most values in attributes, so you don’t have to annotate every property:
Considerations
- The setting applies to every type serialized with the options, so the simple members of nested objects become XML attributes too.
- A mapping attribute on a member always wins. With
Attributeas the default, mark a member with[XmlElement]to keep it as an element. - An XML attribute can’t be marked nil. A member that is
nulland mapped to an attribute is left out, so withAttributeanullvalue and a missing value look the same in the XML. - Attribute names come from
AttributeNamingPolicy, or fromPropertyNamingPolicywhen that isnull. - Use the same options to read the XML back. A member that is mapped to an attribute isn’t read from an element of the same name.
Values
Related APIs
- CloudNimble.Text.Xml.XmlSerializerOptions
- CloudNimble.Text.Xml.Serialization.XmlAttributeAttribute
- CloudNimble.Text.Xml.Serialization.XmlElementAttribute
- CloudNimble.Text.Xml.Serialization.XmlTextAttribute