> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.nimbleapps.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# XmlUnknownTypeHandling

> Defines how [XmlSerializer](/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlSerializer) reads an element into a value declared as [Object](https://learn.microsoft.com...

## Definition

**Assembly:** CloudNimble.XmlEssentials.dll

**Namespace:** CloudNimble.Text.Xml.Serialization

**Inheritance:** System.Enum

## Syntax

```csharp theme={"dark"}
CloudNimble.Text.Xml.Serialization.XmlUnknownTypeHandling
```

## Summary

Defines how [XmlSerializer](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlSerializer.md) reads an element into a value declared as [Object](https://learn.microsoft.com/dotnet/api/system.object).

## Usage

`XmlUnknownTypeHandling` is the type of `XmlSerializerOptions.UnknownTypeHandling`. It says what an element is read as when the declared type is `object`, where the XML can't say which type wrote it. It is the counterpart of `JsonUnknownTypeHandling`.

| Value | A value declared as `object` is read as |
| - | - |
| `XmlElement` | An [`XmlElement`](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlElement), which is read-only. This is the default. |
| `XmlNode` | An [`XmlNode`](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Nodes/XmlNode) that can be changed. The node is an `XmlElementNode`. |

```csharp theme={"dark"}
var options = new XmlSerializerOptions
{
    UnknownTypeHandling = XmlUnknownTypeHandling.XmlNode,
};
```

The option applies to a member, an item of a collection, a value of a dictionary, and the document root. An element marked `xsi:nil="true"` is read as `null` under both values. Writing isn't affected.

## Remarks

A document does not record the type a value had when it was written, so a value declared as
[Object](https://learn.microsoft.com/dotnet/api/system.object) is read as XML. This is the counterpart of
`System.Text.Json.Serialization.JsonUnknownTypeHandling`, whose values are `JsonElement` and
`JsonNode`.

## Values

| Name | Value | Description |
| - | - | - |
| `XmlElement` | 0 | The element is read as an [XmlElement](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlElement.md), which is read-only. |
| `XmlNode` | 1 | The element is read as an [XmlNode](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Nodes/XmlNode.md), which can be changed. The node is an |
| [XmlElementNode](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Nodes/XmlElementNode.md). | | |

## Related APIs

* System.IComparable
* System.ISpanFormattable
* System.IFormattable
* System.IConvertible


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.