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

# XmlCDataAttribute

> Specifies that a member is serialized as the text content of the element for its containing type, written as a CDATA section. This class cannot be inherited.

## Definition

**Assembly:** CloudNimble.XmlEssentials.dll

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

**Inheritance:** System.Attribute

## Syntax

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

## Summary

Specifies that a member is serialized as the text content of the element for its containing type, written as a CDATA section. This class cannot be inherited.

## Usage

Put `[XmlCData]` on a member to make it the text of its containing element, written as a CDATA section. A CDATA section holds characters such as `<` and `&` without escaping, which keeps embedded code or markup readable.

```csharp theme={"dark"}
public sealed class Script
{
    [XmlAttribute("language")]
    public string? Language { get; set; }

    [XmlCData]
    public string? Code { get; set; }
}
```

```csharp theme={"dark"}
var options = new XmlSerializerOptions { OmitXmlDeclaration = true };
var script = new Script { Language = "js", Code = "if (a < b && b > 0) { run(); }" };

string xml = XmlSerializer.Serialize(script, options);
output.WriteLine(xml);

Script? copy = XmlSerializer.Deserialize<Script>(xml, options);
output.WriteLine(copy!.Code);
```

The code produces the following output:

```text theme={"dark"}
<Script language="js"><![CDATA[if (a < b && b > 0) { run(); }]]></Script>
if (a < b && b > 0) { run(); }
```

The member doesn't get an element of its own: `Code` is the content of `<Script>`. The other members of the type are attributes.

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

## Remarks

The member must have a simple type: a type with a built-in value converter, an enumeration, or the nullable form of
either. A type can map one member with this attribute or [XmlTextAttribute](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Serialization/XmlTextAttribute.md), and that type cannot also
map members to child elements.

## Considerations

* `[XmlCData]` follows the rules of `[XmlText]`. A type can have one member with either attribute, and it can't also have members mapped to child elements. The serializer throws `NotSupportedException` otherwise.
* The member must have a simple type: a type with a built-in value converter, an enumeration, or the nullable form of either.
* The attribute affects writing only. When reading, escaped text and CDATA sections are accepted alike, so `<Script>a &lt; b</Script>` gives the same value as the CDATA form.
* A value that contains `]]>` is split at each `]]>` and written as several sections: `a]]>b` is written as `<![CDATA[a]]]]><![CDATA[>b]]>`. A reader joins them again, and the value reads back as it was.
* A `null` value writes no content, which leaves the element empty.
* CDATA is a way of writing text, not a different kind of data. A consumer that parses the document sees the same characters either way.

## Constructors

### &#x20;.ctor

#### Syntax

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

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
protected Attribute()
```

### &#x20;.ctor Inherited

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

#### Syntax

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

## Properties

### &#x20;TypeId Inherited Virtual

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public virtual object TypeId { get; }
```

#### Property Value

Type: `object`

## Methods

### &#x20;Equals Override

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### &#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;GetCustomAttribute Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute GetCustomAttribute(System.Reflection.MemberInfo element, System.Type attributeType)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.MemberInfo` | - |
| `attributeType` | `System.Type` | - |

#### Returns

Type: `System.Attribute?`

### &#x20;GetCustomAttribute Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute GetCustomAttribute(System.Reflection.MemberInfo element, System.Type attributeType, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.MemberInfo` | - |
| `attributeType` | `System.Type` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `System.Attribute?`

### &#x20;GetCustomAttribute Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute GetCustomAttribute(System.Reflection.ParameterInfo element, System.Type attributeType)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.ParameterInfo` | - |
| `attributeType` | `System.Type` | - |

#### Returns

Type: `System.Attribute?`

### &#x20;GetCustomAttribute Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute GetCustomAttribute(System.Reflection.ParameterInfo element, System.Type attributeType, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.ParameterInfo` | - |
| `attributeType` | `System.Type` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `System.Attribute?`

### &#x20;GetCustomAttribute Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute GetCustomAttribute(System.Reflection.Module element, System.Type attributeType)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Module` | - |
| `attributeType` | `System.Type` | - |

#### Returns

Type: `System.Attribute?`

### &#x20;GetCustomAttribute Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute GetCustomAttribute(System.Reflection.Module element, System.Type attributeType, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Module` | - |
| `attributeType` | `System.Type` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `System.Attribute?`

### &#x20;GetCustomAttribute Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute GetCustomAttribute(System.Reflection.Assembly element, System.Type attributeType)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Assembly` | - |
| `attributeType` | `System.Type` | - |

#### Returns

Type: `System.Attribute?`

### &#x20;GetCustomAttribute Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute GetCustomAttribute(System.Reflection.Assembly element, System.Type attributeType, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Assembly` | - |
| `attributeType` | `System.Type` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `System.Attribute?`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.MemberInfo element, System.Type attributeType)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.MemberInfo` | - |
| `attributeType` | `System.Type` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.MemberInfo element, System.Type attributeType, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.MemberInfo` | - |
| `attributeType` | `System.Type` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.MemberInfo element)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.MemberInfo` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.MemberInfo element, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.MemberInfo` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.ParameterInfo element)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.ParameterInfo` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.ParameterInfo element, System.Type attributeType)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.ParameterInfo` | - |
| `attributeType` | `System.Type` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.ParameterInfo element, System.Type attributeType, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.ParameterInfo` | - |
| `attributeType` | `System.Type` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.ParameterInfo element, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.ParameterInfo` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.Module element, System.Type attributeType)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Module` | - |
| `attributeType` | `System.Type` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.Module element)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Module` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.Module element, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Module` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.Module element, System.Type attributeType, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Module` | - |
| `attributeType` | `System.Type` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.Assembly element, System.Type attributeType)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Assembly` | - |
| `attributeType` | `System.Type` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.Assembly element, System.Type attributeType, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Assembly` | - |
| `attributeType` | `System.Type` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.Assembly element)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Assembly` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetCustomAttributes Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static System.Attribute[] GetCustomAttributes(System.Reflection.Assembly element, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Assembly` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `System.Attribute[]`

### &#x20;GetHashCode Override

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

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

#### Returns

Type: `int`

### &#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;IsDefaultAttribute Inherited Virtual

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public virtual bool IsDefaultAttribute()
```

#### Returns

Type: `bool`

### &#x20;IsDefined Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static bool IsDefined(System.Reflection.MemberInfo element, System.Type attributeType)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.MemberInfo` | - |
| `attributeType` | `System.Type` | - |

#### Returns

Type: `bool`

### &#x20;IsDefined Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static bool IsDefined(System.Reflection.MemberInfo element, System.Type attributeType, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.MemberInfo` | - |
| `attributeType` | `System.Type` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `bool`

### &#x20;IsDefined Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static bool IsDefined(System.Reflection.ParameterInfo element, System.Type attributeType)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.ParameterInfo` | - |
| `attributeType` | `System.Type` | - |

#### Returns

Type: `bool`

### &#x20;IsDefined Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static bool IsDefined(System.Reflection.ParameterInfo element, System.Type attributeType, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.ParameterInfo` | - |
| `attributeType` | `System.Type` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `bool`

### &#x20;IsDefined Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static bool IsDefined(System.Reflection.Module element, System.Type attributeType)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Module` | - |
| `attributeType` | `System.Type` | - |

#### Returns

Type: `bool`

### &#x20;IsDefined Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static bool IsDefined(System.Reflection.Module element, System.Type attributeType, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Module` | - |
| `attributeType` | `System.Type` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `bool`

### &#x20;IsDefined Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static bool IsDefined(System.Reflection.Assembly element, System.Type attributeType)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Assembly` | - |
| `attributeType` | `System.Type` | - |

#### Returns

Type: `bool`

### &#x20;IsDefined Inherited

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

```csharp theme={"dark"}
public static bool IsDefined(System.Reflection.Assembly element, System.Type attributeType, bool inherit)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `element` | `System.Reflection.Assembly` | - |
| `attributeType` | `System.Type` | - |
| `inherit` | `bool` | - |

#### Returns

Type: `bool`

### &#x20;Match Inherited Virtual

> [!NOTE]
>
> Inherited from `System.Attribute`

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### &#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.XmlTextAttribute
* CloudNimble.Text.Xml.Serialization.XmlAttributeAttribute
* CloudNimble.Text.Xml.Serialization.XmlMixedAttribute
* CloudNimble.Text.Xml.Utf8XmlWriter


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