> ## 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.

# XmlMixedContentItem

> Defines the core behavior of an item of mixed content and provides a base for [XmlMixedText](/xmlessentials/api-reference/CloudNimble/Text/Xml/Serialization/XmlMixedText) ...

## Definition

**Assembly:** CloudNimble.XmlEssentials.dll

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

## Syntax

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

## Summary

Defines the core behavior of an item of mixed content and provides a base for [XmlMixedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Serialization/XmlMixedText.md) and [XmlMixedElement](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Serialization/XmlMixedElement.md).

## Usage

`XmlMixedContentItem` is the abstract base of the two kinds of item in a mixed-content list: `XmlMixedText` for a run of text and `XmlMixedElement` for a child element. Use it as the element type of the list that you mark with `[XmlMixed]`, and use pattern matching to tell the items apart.

```csharp theme={"dark"}
string xml = "<Paragraph>Press <Key>Ctrl</Key> and <Key>S</Key> to save.</Paragraph>";

Paragraph? paragraph = XmlSerializer.Deserialize<Paragraph>(xml);
foreach (XmlMixedContentItem item in paragraph!.Content)
{
    switch (item)
    {
        case XmlMixedText text:
            output.WriteLine($"Text: \"{text.Text}\"");
            break;
        case XmlMixedElement { Element: { } element }:
            output.WriteLine($"Element: {element.LocalName} = {element.InnerText}");
            break;
    }
}
```

The loop prints the following:

```text theme={"dark"}
Text: "Press "
Element: Key = Ctrl
Text: " and "
Element: Key = S
Text: " to save."
```

The class has no members of its own. The serializer writes only `XmlMixedText` and `XmlMixedElement` items, and skips an item of any other derived type.

[View the complete sample on GitHub](https://github.com/CloudNimble/XmlEssentials/blob/main/src/CloudNimble.XmlEssentials.Samples/18_MixedContent.cs)

## Constructors

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public Object()
```

## Methods

### &#x20;Equals Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual bool Equals(object obj)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `obj` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;Equals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool Equals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;GetHashCode Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual int GetHashCode()
```

#### Returns

Type: `int`

### &#x20;GetType Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public System.Type GetType()
```

#### Returns

Type: `System.Type`

### &#x20;MemberwiseClone Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
protected internal object MemberwiseClone()
```

#### Returns

Type: `object`

### &#x20;ReferenceEquals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool ReferenceEquals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;ToString Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual string ToString()
```

#### Returns

Type: `string?`

## Related APIs

* CloudNimble.Text.Xml.Serialization.XmlMixedAttribute
* CloudNimble.Text.Xml.Serialization.XmlMixedText
* CloudNimble.Text.Xml.Serialization.XmlMixedElement


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