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

# Utf8XmlWriter

> Provides a forward-only, non-cached writer for UTF-8 encoded XML text. This class cannot be inherited.

## Definition

**Assembly:** CloudNimble.XmlEssentials.dll

**Namespace:** CloudNimble.Text.Xml

## Syntax

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

## Summary

Provides a forward-only, non-cached writer for UTF-8 encoded XML text. This class cannot be inherited.

## Usage

Create a writer over an `IBufferWriter<byte>` or a `Stream`, write the document with one call per start tag, attribute, value, and end tag, and dispose the writer to flush it.

```csharp theme={"dark"}
var buffer = new ArrayBufferWriter<byte>();
var options = new XmlWriterOptions { Indented = true, NewLine = "\n" };

using (var writer = new Utf8XmlWriter(buffer, options))
{
    writer.WriteStartElement("Order");
    writer.WriteAttributeString("id", "1042");

    writer.WriteStartElement("Customer");
    writer.WriteStringValue("Ada Lovelace");
    writer.WriteEndElement();

    writer.WriteStartElement("Total");
    writer.WriteAttributeString("currency", "EUR");
    writer.WriteNumberValue(129.90m);
    writer.WriteEndElement();

    writer.WriteStartElement("Notes");
    writer.WriteEndElement();

    writer.WriteEndElement();
}

output.WriteLine(Encoding.UTF8.GetString(buffer.WrittenSpan));
```

```xml theme={"dark"}
<?xml version="1.0" encoding="utf-8"?>
<Order id="1042">
  <Customer>Ada Lovelace</Customer>
  <Total currency="EUR">129.90</Total>
  <Notes/>
</Order>
```

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

The members you use most:

| To | Use |
| - | - |
| Open and close an element | `WriteStartElement`, `WriteEndElement`, `WriteFullEndElement` |
| Write an attribute | `WriteAttributeString`, `WriteAttributeNumber`, or `WriteStartAttribute` and `WriteEndAttribute` around a value |
| Write a value | `WriteStringValue`, `WriteNumberValue`, `WriteBooleanValue`, `WriteBase64StringValue` |
| Write a value from several buffers | `WriteStringValueSegment`, `WriteBase64StringSegment` |
| Write a complete element | `WriteElementString`, `WriteElementNumber`, `WriteElementBoolean`, `WriteElementBase64String`, `WriteEmptyElement`, `WriteNilElement` |
| Mark the open element nil | `WriteNilValue` |
| Declare a namespace yourself | `WriteNamespaceDeclaration`, `WriteDefaultNamespace` |
| Write other markup | `WriteComment`, `WriteCData`, `WriteProcessingInstruction`, `WriteXmlDeclaration`, `WriteRawValue` |
| Send output on its way | `Flush`, `FlushAsync`, `Dispose`, `DisposeAsync` |
| See where the writer is | `BytesPending`, `BytesCommitted`, `CurrentDepth` |
| Write another document | `Reset` |

Most methods take names and values as a `string`, a `ReadOnlySpan<char>`, or UTF-8 in a `ReadOnlySpan<byte>`, and element names also as an [`XmlEncodedText`](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText). Pass an [`XmlWriterOptions`](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions) to the constructor to indent, to leave out the declaration, or to change a limit.

For a walk through every feature, see [How to write XML with Utf8XmlWriter](https://easyaf.nimbleapps.cloud/xmlessentials/guides/use-utf8xmlwriter.md).

## Remarks

The API follows the shape of `Utf8JsonWriter`. The writer writes to an [IBufferWriter\`1](https://learn.microsoft.com/dotnet/api/system.buffers.ibufferwriter-1)
or to a [Stream](https://learn.microsoft.com/dotnet/api/system.io.stream), and the output is always UTF-8. Names and values can be passed as strings,
as spans of characters, or as spans of UTF-8 bytes.

A limit on [XmlWriterOptions](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md) that is 0 uses its default: 64 for [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth),
1000 for [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount), and 1024 for [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount).

[Utf8XmlWriter.Dispose](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#dispose) and [Utf8XmlWriter.DisposeAsync](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#disposeasync) flush the output. If elements are still open and
[XmlWriterOptions.SkipValidation](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#skipvalidation) is [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool), they then throw an
[XmlException](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlException.md), so the output written so far is not lost with the error.

## Examples

Each example is a sample in the repository whose output is checked by a test.

### Write complete elements

```csharp theme={"dark"}
var buffer = new ArrayBufferWriter<byte>();
var options = new XmlWriterOptions { Indented = true, NewLine = "\n", OmitXmlDeclaration = true };

using (var writer = new Utf8XmlWriter(buffer, options))
{
    writer.WriteStartElement("Order");
    writer.WriteElementString("Item", "Keyboard");
    writer.WriteElementNumber("Quantity", 2);
    writer.WriteElementNumber("Total", 129.90m);
    writer.WriteElementBoolean("Rush", true);
    writer.WriteElementString("Placed", new DateTime(2026, 3, 14, 9, 30, 0, DateTimeKind.Utc));
    writer.WriteElementBase64String("Signature", [0x58, 0x4D, 0x4C, 0x21]);
    writer.WriteElementString("Comment", (string?)null);
    writer.WriteEmptyElement("Gift");
    writer.WriteNilElement("Discount");

    writer.WriteStartElement("Notes");
    writer.WriteFullEndElement();

    writer.WriteEndElement();
}

output.WriteLine(Encoding.UTF8.GetString(buffer.WrittenSpan));
```

```xml theme={"dark"}
<Order>
  <Item>Keyboard</Item>
  <Quantity>2</Quantity>
  <Total>129.90</Total>
  <Rush>true</Rush>
  <Placed>2026-03-14T09:30:00Z</Placed>
  <Signature>WE1MIQ==</Signature>
  <Comment/>
  <Gift/>
  <Discount xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
  <Notes></Notes>
</Order>
```

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

### Write namespaces

Pass the namespace URI, and the writer chooses or declares the prefix.

```csharp theme={"dark"}
const string atom = "http://www.w3.org/2005/Atom";
const string dublinCore = "http://purl.org/dc/elements/1.1/";
const string shop = "urn:example:shop";

var buffer = new ArrayBufferWriter<byte>();
var options = new XmlWriterOptions { Indented = true, NewLine = "\n", OmitXmlDeclaration = true };

using (var writer = new Utf8XmlWriter(buffer, options))
{
    // The writer declares the default namespace because nothing in scope is bound to it.
    writer.WriteStartElement("feed", atom);

    // Declare a prefix on the root so that every descendant can use it.
    writer.WriteNamespaceDeclaration("dc", dublinCore);

    // The namespace is the default one in scope, so the element needs no prefix.
    writer.WriteElementString("title", atom, "Orders");

    // The namespace is bound to dc, so the writer uses that prefix.
    writer.WriteElementString("creator", dublinCore, "Ada");

    // A prefix and a namespace that are not in scope: the writer declares them on this element.
    writer.WriteStartElement("s", "order", shop);
    writer.WriteAttributeString("s", "id", shop, "1042");
    writer.WriteEndElement();

    // An attribute in a namespace that has no prefix in scope gets a generated one.
    writer.WriteStartElement("entry", atom);
    writer.WriteAttributeString("priority", shop, "high");
    writer.WriteAttributeString("lang", "en");
    writer.WriteEndElement();

    writer.WriteEndElement();
}

output.WriteLine(Encoding.UTF8.GetString(buffer.WrittenSpan));
```

```xml theme={"dark"}
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Orders</title>
  <dc:creator>Ada</dc:creator>
  <s:order xmlns:s="urn:example:shop" s:id="1042"/>
  <entry xmlns:ns1="urn:example:shop" ns1:priority="high" lang="en"/>
</feed>
```

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

### Reuse one writer for several documents

```csharp theme={"dark"}
var buffer = new ArrayBufferWriter<byte>();
using var writer = new Utf8XmlWriter(buffer, new XmlWriterOptions { OmitXmlDeclaration = true });

string[] items = ["Keyboard", "Mouse", "Monitor"];
foreach (var item in items)
{
    writer.WriteStartElement("Item");
    writer.WriteStringValue(item);
    writer.WriteEndElement();
    writer.Flush();

    output.WriteLine($"{Encoding.UTF8.GetString(buffer.WrittenSpan)} ({writer.BytesCommitted} bytes)");

    buffer.ResetWrittenCount();
    writer.Reset();
}

var other = new ArrayBufferWriter<byte>();
writer.Reset(other);
writer.WriteEmptyElement("Done");
writer.Flush();
output.WriteLine($"Second buffer: {Encoding.UTF8.GetString(other.WrittenSpan)}");
```

```text theme={"dark"}
<Item>Keyboard</Item> (21 bytes)
<Item>Mouse</Item> (18 bytes)
<Item>Monitor</Item> (20 bytes)
Second buffer: <Done/>
```

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

## Best Practices

* **Dispose the writer, or call `Flush`, before you read the output.** Until then, bytes are pending and the buffer or stream doesn't have them.
* **End every element yourself.** `Dispose` throws an `XmlException` when an element is still open. It doesn't close elements for you.
* **Use the `WriteElement*` methods for elements that hold one value.** One call replaces three.
* **Pass `u8` literals for names that are fixed.** `writer.WriteStartElement("Order"u8)` skips the conversion from UTF-16. For a name computed once at run time, keep an `XmlEncodedText`.
* **Declare the prefixes you use often on the root element** with `WriteNamespaceDeclaration`. Otherwise the writer declares a prefix again on every element that needs it and isn't inside one that has it.
* **Reuse a writer with `Reset` on a hot path.** A reused writer allocates nothing per document. Call `Flush` before `Reset`, because `Reset` discards pending bytes.
* **Set `NewLine` when the bytes matter.** The default depends on the operating system.
* **Write binary data that's in one buffer with one `WriteBase64StringValue` call.** Use `WriteBase64StringSegment` only when the data arrives in pieces.
* **Use `WriteRawValue` only for XML that your own code produced.** The input isn't escaped. By default the writer checks that it's well formed where it goes, but well-formed input can still carry markup you didn't intend.
* **Discard the output when the writer throws.** Part of the document may already be committed.

## Patterns

These are the shapes that code using the writer takes most often.

### Element with attributes and content

Call `WriteStartElement`, then the attributes and namespace declarations, then the content, then `WriteEndElement`. The start tag closes when you write the first content, and attributes aren't accepted after that.

### Leaf element

`WriteElementString`, `WriteElementNumber`, `WriteElementBoolean`, and `WriteElementBase64String` write a start tag, a value, and an end tag in one call. `WriteEmptyElement` writes an element with no content, `<e/>` unless `XmlWriterOptions.EmptyElementStyle` says otherwise, and `WriteNilElement` writes an empty element with `xsi:nil="true"`.

### Attribute with a typed value

`WriteAttributeString` takes text and `WriteAttributeNumber` takes an `int`, a `long`, or a `double`. For any other type, open the attribute with `WriteStartAttribute`, call a value method such as `WriteBooleanValue` or `WriteStringValue(DateTimeOffset)`, and close it with `WriteEndAttribute`.

### One writer, many documents

Create the writer once, and after each document call `Flush` and then `Reset`. `Reset` discards anything that isn't flushed. Use `Reset(IBufferWriter<byte>)` or `Reset(Stream)` to send the next document somewhere else.

### Stream with asynchronous flushes

Write with the synchronous methods, which only fill the writer's buffer, and call `await writer.FlushAsync()` at points where a batch is complete. Dispose with `await using`.

### Copy a parsed document

`XmlDocument.WriteTo` and `XmlElement.WriteTo` write a parsed document, or one element of it, into a writer. See [How to use XmlDocument](https://easyaf.nimbleapps.cloud/xmlessentials/guides/use-xmldocument.md).

### Custom converter

`XmlConverter<T>.Write` receives the writer, positioned where the value goes. See [Custom converters](https://easyaf.nimbleapps.cloud/xmlessentials/guides/custom-converters.md).

## Considerations

Know the following before you build on the writer.

### Output and buffering

The output is always UTF-8. With an `IBufferWriter<byte>`, the writer writes into memory it gets from the buffer writer and commits it on `Flush`, on `Dispose`, and when it needs more room. With a `Stream`, it fills a buffer rented from the array pool, which starts at 16 KB, and writes to the stream on `Flush`, on `Dispose`, and when the buffer fills. Disposing the writer doesn't close the stream.

### Dispose and open elements

`Dispose` and `DisposeAsync` flush. If an element is still open and `SkipValidation` is `false`, they flush and then throw an `XmlException`. In a `using` statement, that exception replaces an exception that was already on its way out, so the message you catch can be `The document has unclosed elements.` when the real cause came earlier.

### Thread safety

A writer isn't thread safe. Use each instance from one thread at a time. See [Thread safety](https://easyaf.nimbleapps.cloud/xmlessentials/guides/thread-safety.md).

### Allocation

A writer that's reused with `Reset` allocates nothing per document. `Reset` discards bytes that are still pending, so call `Flush` first to keep them. See [Benchmarks](https://easyaf.nimbleapps.cloud/xmlessentials/benchmarks.md) for the measurements.

### Namespaces

The writer tracks the namespaces in scope and declares what's missing: a default namespace for an element written with a namespace and no prefix, your prefix for an element written with one, and a generated prefix (`ns1`, `ns2`, and so on) for an attribute in a namespace that has no prefix in scope. An element written with no namespace argument, or with a `null` one, gets no declaration, so under a default namespace a reader puts it in that namespace. An element written with an empty namespace is in no namespace: under a default namespace the writer adds `xmlns=""`.

### Indentation

With `Indented` set, elements, comments, and processing instructions each get a line break and indentation. An element that holds text, a CDATA section, or raw XML from `WriteRawValue` is written on one line, with everything in it.

### Layout

Every line break the writer writes is the `NewLine` of its options, including a line feed inside text, a CDATA section, a comment, or a processing instruction. An element with no content is written in the form `EmptyElementStyle` asks for (`<e/>` by default), except after `WriteFullEndElement`, which always writes an end tag. `AttributeStyle` decides whether attributes stay on the line of the start tag.

### What isn't checked

* `WriteRawValue` copies its input without escaping it. It checks that the input is well formed where it is written only when `skipInputValidation` is `false` and the writer does not have `SkipValidation` set.
* With `SkipValidation` set, names, namespace declarations, duplicate attributes, the characters of comments, CDATA sections, and processing instructions, and unclosed elements at `Dispose` aren't checked. Values are still escaped, and the single root, `MaxDepth`, and `MaxAttributeCount` are still enforced.

### Differences from Utf8JsonWriter

* There's no property-name step. Structure comes from `WriteStartElement` and `WriteEndElement`, and attributes are written on the open start tag.
* Validation is on by default and also covers names and namespaces. `SkipValidation` doesn't turn off the single-root check, `MaxDepth`, or `MaxAttributeCount`.
* `Dispose` throws when the document is incomplete.

### Differences from System.Xml.XmlWriter

* The output is UTF-8 only, to an `IBufferWriter<byte>` or a `Stream`. There's no `TextWriter` or `StringBuilder` target.
* There's no `WriteDocType`, `WriteEntityRef`, `WriteStartDocument`, or `WriteEndDocument`. The declaration is written for you, and nothing closes open elements for you.
* `Reset` lets one instance write many documents.
* Typed values have their own methods, in place of `WriteValue` overloads and `XmlConvert`.

## Constructors

### &#x20;.ctor

Initializes a new instance of the [Utf8XmlWriter](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md) class using the specified
[IBufferWriter\`1](https://learn.microsoft.com/dotnet/api/system.buffers.ibufferwriter-1) to write the output to and customization options.

#### Syntax

```csharp theme={"dark"}
public Utf8XmlWriter(System.Buffers.IBufferWriter<byte> bufferWriter, CloudNimble.Text.Xml.XmlWriterOptions options = default(CloudNimble.Text.Xml.XmlWriterOptions))
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `bufferWriter` | `System.Buffers.IBufferWriter<byte>` | The destination for writing XML text. |
| `options` | `CloudNimble.Text.Xml.XmlWriterOptions` | The options that define the customized behavior of the writer. The default value writes XML that is |
| not indented, with an XML declaration, and with validation. | | |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *bufferWriter* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

### &#x20;.ctor

Initializes a new instance of the [Utf8XmlWriter](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md) class using the specified stream to
write the output to and customization options.

#### Syntax

```csharp theme={"dark"}
public Utf8XmlWriter(System.IO.Stream utf8Xml, CloudNimble.Text.Xml.XmlWriterOptions options = default(CloudNimble.Text.Xml.XmlWriterOptions))
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8Xml` | `System.IO.Stream` | The destination for writing XML text. |
| `options` | `CloudNimble.Text.Xml.XmlWriterOptions` | The options that define the customized behavior of the writer. The default value writes XML that is |
| not indented, with an XML declaration, and with validation. | | |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *utf8Xml* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

### &#x20;.ctor Inherited

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

#### Syntax

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

## Properties

### &#x20;BytesCommitted

Gets the total number of bytes committed to the output by the current instance so far.

#### Syntax

```csharp theme={"dark"}
public long BytesCommitted { get; }
```

#### Property Value

Type: `long`
The number of bytes committed to the output. [Utf8XmlWriter.Reset](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#reset) sets the value back to 0.

### &#x20;BytesPending

Gets the number of bytes written by the [Utf8XmlWriter](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md) so far that have not yet been
flushed to the output and committed.

#### Syntax

```csharp theme={"dark"}
public int BytesPending { get; }
```

#### Property Value

Type: `int`
The number of bytes written so far that have not yet been flushed to the output and committed.

### &#x20;CurrentDepth

Gets the depth of the current element.

#### Syntax

```csharp theme={"dark"}
public int CurrentDepth { get; }
```

#### Property Value

Type: `int`
The number of elements that are open. The value is 0 at the document level, and 1 from the start tag
of the root element to its end tag.

### &#x20;Options

Gets the custom behavior when writing XML using this instance, which indicates whether to format the
output while writing, whether to skip validation, and which limits apply.

#### Syntax

```csharp theme={"dark"}
public CloudNimble.Text.Xml.XmlWriterOptions Options { get; }
```

#### Property Value

Type: `CloudNimble.Text.Xml.XmlWriterOptions`
The options that were passed to the constructor of this instance.

## Methods

### &#x20;Dispose

#### Syntax

```csharp theme={"dark"}
public void Dispose()
```

### &#x20;DisposeAsync

#### Syntax

```csharp theme={"dark"}
public System.Threading.Tasks.ValueTask DisposeAsync()
```

#### Returns

Type: `System.Threading.Tasks.ValueTask`

### &#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;Flush

Commits the XML text written so far, which makes it visible to the output destination.

#### Syntax

```csharp theme={"dark"}
public void Flush()
```

#### Exceptions

| Exception | Description |
| - | - |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

In the case of [IBufferWriter`1](https://learn.microsoft.com/dotnet/api/system.buffers.ibufferwriter-1), this advances the underlying [IBufferWriter`1](https://learn.microsoft.com/dotnet/api/system.buffers.ibufferwriter-1)
based on what has been written so far. In the case of [Stream](https://learn.microsoft.com/dotnet/api/system.io.stream), this writes the data to the
stream and flushes it.

### &#x20;FlushAsync

Asynchronously commits the XML text written so far, which makes it visible to the output destination.

#### Syntax

```csharp theme={"dark"}
public System.Threading.Tasks.Task FlushAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `cancellationToken` | `System.Threading.CancellationToken` | The token to monitor for cancellation requests. The default value is [None](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken.none). |

#### Returns

Type: `System.Threading.Tasks.Task`
A task representing the asynchronous flush operation.

#### Exceptions

| Exception | Description |
| - | - |
| `ObjectDisposedException` | This instance has been disposed. This exception is stored into the returned task. |

#### Remarks

In the case of [IBufferWriter`1](https://learn.microsoft.com/dotnet/api/system.buffers.ibufferwriter-1), this advances the underlying [IBufferWriter`1](https://learn.microsoft.com/dotnet/api/system.buffers.ibufferwriter-1)
based on what has been written so far. In the case of [Stream](https://learn.microsoft.com/dotnet/api/system.io.stream), this writes the data to the
stream and flushes it asynchronously, while monitoring cancellation requests.

### &#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;Reset

Resets the internal state of this instance so that it can be reused to write a new document.

#### Syntax

```csharp theme={"dark"}
public void Reset()
```

#### Exceptions

| Exception | Description |
| - | - |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The writer continues to use the original writer options and the original output
(either \[IBufferWriter`1](https://learn.microsoft.com/dotnet/api/system.buffers.ibufferwriter-1) or [Stream](https://learn.microsoft.com/dotnet/api/system.io.stream)). Bytes that are still pending are
discarded, as `Utf8JsonWriter.Reset\` discards them, and [Utf8XmlWriter.BytesCommitted](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#bytescommitted) is set to 0.
Call [Utf8XmlWriter.Flush](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#flush) first to keep what has been written.

### &#x20;Reset

Resets the internal state of this instance so that it can be reused with a new instance of
[IBufferWriter\`1](https://learn.microsoft.com/dotnet/api/system.buffers.ibufferwriter-1).

#### Syntax

```csharp theme={"dark"}
public void Reset(System.Buffers.IBufferWriter<byte> bufferWriter)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `bufferWriter` | `System.Buffers.IBufferWriter<byte>` | The destination for writing XML text. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *bufferWriter* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The writer continues to use the original writer options but now writes to *bufferWriter*
as the new output. Bytes that are still pending are discarded; call [Utf8XmlWriter.Flush](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#flush) first to commit
them to the previous output.

### &#x20;Reset

Resets the internal state of this instance so that it can be reused with a new instance of
[Stream](https://learn.microsoft.com/dotnet/api/system.io.stream).

#### Syntax

```csharp theme={"dark"}
public void Reset(System.IO.Stream utf8Xml)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8Xml` | `System.IO.Stream` | The destination for writing XML text. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *utf8Xml* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The writer continues to use the original writer options but now writes to *utf8Xml*
as the new output. Bytes that are still pending are discarded; call [Utf8XmlWriter.Flush](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#flush) first to commit
them to the previous output.

### &#x20;ToString Inherited Virtual

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

#### Syntax

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

#### Returns

Type: `string?`

### &#x20;WriteAttributeNumber

Writes an attribute with the name specified as a string and an [Int32](https://learn.microsoft.com/dotnet/api/system.int32) value.

#### Syntax

```csharp theme={"dark"}
public void WriteAttributeNumber(string name, int value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `name` | `string` | The name of the attribute, without a prefix. |
| `value` | `int` | The number to write as the value of the attribute. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *name* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | No start tag is open, or another attribute is still open. |
| -or- | |
| *name* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). | |
| -or- | |
| The element already has an attribute with the same name, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |

### &#x20;WriteAttributeNumber

Writes an attribute with the name specified as a string and a [Int64](https://learn.microsoft.com/dotnet/api/system.int64) value.

#### Syntax

```csharp theme={"dark"}
public void WriteAttributeNumber(string name, long value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `name` | `string` | The name of the attribute, without a prefix. |
| `value` | `long` | The number to write as the value of the attribute. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *name* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | No start tag is open, or another attribute is still open. |
| -or- | |
| *name* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). | |
| -or- | |
| The element already has an attribute with the same name, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |

### &#x20;WriteAttributeNumber

Writes an attribute with the name specified as a string and a [Double](https://learn.microsoft.com/dotnet/api/system.double) value.

#### Syntax

```csharp theme={"dark"}
public void WriteAttributeNumber(string name, double value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `name` | `string` | The name of the attribute, without a prefix. |
| `value` | `double` | The number to write as the value of the attribute. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *name* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | No start tag is open, or another attribute is still open. |
| -or- | |
| *name* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). | |
| -or- | |
| The element already has an attribute with the same name, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |

#### Remarks

Not-a-number is written as `NaN`, positive infinity as `INF`, and negative infinity as `-INF`.

### &#x20;WriteAttributeString

Writes an attribute with the name and the value specified as strings.

#### Syntax

```csharp theme={"dark"}
public void WriteAttributeString(string name, string value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `name` | `string` | The name of the attribute, without a prefix. |
| `value` | `string?` | The value of the attribute, escaped as needed, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to write an empty value. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *name* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | No start tag is open, or another attribute is still open. |
| -or- | |
| *name* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). | |
| -or- | |
| The element already has an attribute with the same name, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |
| -or- | |
| *value* contains a character that XML does not allow. | |

### &#x20;WriteAttributeString

Writes an attribute with the local name, the namespace URI, and the value specified as strings.

#### Syntax

```csharp theme={"dark"}
public void WriteAttributeString(string localName, string namespaceUri, string value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the attribute. |
| `namespaceUri` | `string?` | The namespace URI of the attribute, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or an empty string for none. |
| `value` | `string?` | The value of the attribute, escaped as needed, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to write an empty value. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | No start tag is open, or another attribute is still open. |
| -or- | |
| *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). | |
| -or- | |
| The element already has an attribute with the same local name and namespace URI, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |
| -or- | |
| *value* contains a character that XML does not allow. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The namespace is handled as it is by [Utf8XmlWriter.WriteStartAttribute](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestartattribute).

### &#x20;WriteAttributeString

Writes an attribute with the prefix, the local name, the namespace URI, and the value specified as strings.

#### Syntax

```csharp theme={"dark"}
public void WriteAttributeString(string prefix, string localName, string namespaceUri, string value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `prefix` | `string?` | The prefix of the attribute, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or an empty string for none. |
| `localName` | `string` | The local name of the attribute. |
| `namespaceUri` | `string?` | The namespace URI of the attribute, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or an empty string for none. |
| `value` | `string?` | The value of the attribute, escaped as needed, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to write an empty value. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | No start tag is open, or another attribute is still open. |
| -or- | |
| *localName* or *prefix* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). | |
| -or- | |
| *prefix* is a prefix other than `xml` and `xmlns`, and *namespaceUri* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or empty. | |
| -or- | |
| The element already has an attribute with the same local name and namespace URI, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |
| -or- | |
| *value* contains a character that XML does not allow. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The namespace is handled as it is by [Utf8XmlWriter.WriteStartAttribute](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestartattribute).

### &#x20;WriteAttributeString

Writes an attribute with the name and the value specified as read-only spans of UTF-8 bytes.

#### Syntax

```csharp theme={"dark"}
public void WriteAttributeString(System.ReadOnlySpan<byte> utf8Name, System.ReadOnlySpan<byte> utf8Value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8Name` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded name of the attribute, without a prefix. |
| `utf8Value` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded value of the attribute, escaped as needed. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | No start tag is open, or another attribute is still open. |
| -or- | |
| *utf8Name* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). | |
| -or- | |
| The element already has an attribute with the same name, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |
| -or- | |
| *utf8Value* is not valid UTF-8, or contains a character that XML does not allow. | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteAttributeString

Writes an attribute with the name and the value specified as read-only spans of characters.

#### Syntax

```csharp theme={"dark"}
public void WriteAttributeString(System.ReadOnlySpan<char> name, System.ReadOnlySpan<char> value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `name` | `System.ReadOnlySpan<char>` | The name of the attribute, without a prefix. |
| `value` | `System.ReadOnlySpan<char>` | The value of the attribute, escaped as needed. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | No start tag is open, or another attribute is still open. |
| -or- | |
| *name* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). | |
| -or- | |
| The element already has an attribute with the same name, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |
| -or- | |
| *value* contains a character that XML does not allow. | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteBase64StringSegment

Writes a segment of binary data as base64 encoded text to the content of the current element or to the
value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteBase64StringSegment(System.ReadOnlySpan<byte> value, bool isFinalSegment)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `System.ReadOnlySpan<byte>` | The segment of the binary data to write as base64 encoded text. |
| `isFinalSegment` | `bool` | [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to indicate that this is the final segment of the binary data; otherwise, [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| -or- | |
| A value of another kind is being written in segments. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Examples

```csharp theme={"dark"}
writer.WriteStartElement("data");
writer.WriteBase64StringSegment([1], isFinalSegment: false);
writer.WriteBase64StringSegment([2], isFinalSegment: true);
writer.WriteEndElement();
// <data>AQI=</data>
```

#### Remarks

The segments together are written as [Utf8XmlWriter.WriteBase64StringValue](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writebase64stringvalue) writes the
whole data: one base64 value, padded only at its end. A segment can be any length. The writer keeps the
one or two bytes that do not fill a group of three and encodes them with the next segment. After a
segment that is not final, the next call on the writer must be the next segment, apart from
[Utf8XmlWriter.Flush](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#flush) and [Utf8XmlWriter.FlushAsync](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#flushasync); any other call throws an
[XmlException](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlException.md).

### &#x20;WriteBase64StringValue

Writes binary data as base64 encoded text to the content of the current element or to the value of the
current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteBase64StringValue(System.ReadOnlySpan<byte> bytes)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `bytes` | `System.ReadOnlySpan<byte>` | The binary data to write as base64 encoded text. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteBooleanValue

Writes a [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean) value (as the XML literal `true` or `false`) to the content of the
current element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteBooleanValue(bool value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `bool` | [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to write `true`; [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to write `false`. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteCData

Writes a CDATA section (`<![CDATA[...]]>`) with the text specified as a string.

#### Syntax

```csharp theme={"dark"}
public void WriteCData(string text)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `text` | `string` | The text of the CDATA section. It is written as it is, without escaping. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *text* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | The writer is not inside an element. |
| -or- | |
| *text* contains `]]>`. | |
| -or- | |
| *text* contains a character that XML does not allow. | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteCData

Writes a CDATA section (`<![CDATA[...]]>`) with the text specified as a read-only span of characters.

#### Syntax

```csharp theme={"dark"}
public void WriteCData(System.ReadOnlySpan<char> text)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `text` | `System.ReadOnlySpan<char>` | The text of the CDATA section. It is written as it is, without escaping. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element. |
| -or- | |
| *text* contains `]]>`. | |
| -or- | |
| *text* contains a character that XML does not allow. | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteCData

Writes a CDATA section (`<![CDATA[...]]>`) with the text specified as a read-only span of UTF-8 bytes.

#### Syntax

```csharp theme={"dark"}
public void WriteCData(System.ReadOnlySpan<byte> utf8Value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8Value` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded text of the CDATA section. It is written as it is, without escaping. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element. |
| -or- | |
| *utf8Value* contains `]]>`. | |
| -or- | |
| *utf8Value* is not valid UTF-8, or contains a character that XML does not allow. | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteComment

Writes a comment (`<!--...-->`) with the text specified as a string.

#### Syntax

```csharp theme={"dark"}
public void WriteComment(string value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `string` | The text of the comment. It is written as it is, without escaping. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *value* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *value* contains `--` or ends with `-`. |
| -or- | |
| *value* contains a character that XML does not allow. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

A comment can be written inside an element, and before or after the root element.

### &#x20;WriteComment

Writes a comment (`<!--...-->`) with the text specified as a read-only span of characters.

#### Syntax

```csharp theme={"dark"}
public void WriteComment(System.ReadOnlySpan<char> value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `System.ReadOnlySpan<char>` | The text of the comment. It is written as it is, without escaping. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *value* contains `--` or ends with `-`. |
| -or- | |
| *value* contains a character that XML does not allow. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

A comment can be written inside an element, and before or after the root element.

### &#x20;WriteComment

Writes a comment (`<!--...-->`) with the text specified as a read-only span of UTF-8 bytes.

#### Syntax

```csharp theme={"dark"}
public void WriteComment(System.ReadOnlySpan<byte> utf8Value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8Value` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded text of the comment. It is written as it is, without escaping. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8Value* contains `--` or ends with `-`. |
| -or- | |
| *utf8Value* is not valid UTF-8, or contains a character that XML does not allow. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

A comment can be written inside an element, and before or after the root element.

### &#x20;WriteDefaultNamespace

Writes a default namespace declaration (`xmlns="namespaceUri"`) on the start tag of the current
element, with the namespace URI specified as a string.

#### Syntax

```csharp theme={"dark"}
public void WriteDefaultNamespace(string namespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `namespaceUri` | `string` | The namespace URI to declare as the default namespace. An empty string removes the default namespace. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *namespaceUri* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | No start tag is open, or an attribute is still open. |
| -or- | |
| *namespaceUri* is the `xml` or the `xmlns` namespace. | |
| -or- | |
| The element already declares a default namespace, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The binding is in scope for the element and its descendants. A declaration counts as an attribute
toward [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount).

### &#x20;WriteDefaultNamespace

Writes a default namespace declaration (`xmlns="namespaceUri"`) on the start tag of the current
element, with the namespace URI specified as a read-only span of UTF-8 bytes.

#### Syntax

```csharp theme={"dark"}
public void WriteDefaultNamespace(System.ReadOnlySpan<byte> utf8NamespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8NamespaceUri` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded namespace URI to declare as the default namespace. An empty span removes the default namespace. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | No start tag is open, or an attribute is still open. |
| -or- | |
| *utf8NamespaceUri* is the `xml` or the `xmlns` namespace. | |
| -or- | |
| The element already declares a default namespace, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The binding is in scope for the element and its descendants. A declaration counts as an attribute
toward [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount).

### &#x20;WriteElementBase64String

Writes an element with the local name specified as a string and binary data, encoded as base64 text, as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementBase64String(string localName, System.ReadOnlySpan<byte> bytes)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `bytes` | `System.ReadOnlySpan<byte>` | The binary data to write as base64 encoded text. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementBase64String

Writes an element with the local name specified as a read-only span of characters and binary data,
encoded as base64 text, as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementBase64String(System.ReadOnlySpan<char> localName, System.ReadOnlySpan<byte> bytes)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `bytes` | `System.ReadOnlySpan<byte>` | The binary data to write as base64 encoded text. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementBase64String

Writes an element with the local name specified as a read-only span of UTF-8 bytes and binary data,
encoded as base64 text, as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementBase64String(System.ReadOnlySpan<byte> utf8LocalName, System.ReadOnlySpan<byte> bytes)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `bytes` | `System.ReadOnlySpan<byte>` | The binary data to write as base64 encoded text. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementBase64String

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and binary data, encoded as base64 text, as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementBase64String(CloudNimble.Text.Xml.XmlEncodedText localName, System.ReadOnlySpan<byte> bytes)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `bytes` | `System.ReadOnlySpan<byte>` | The binary data to write as base64 encoded text. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementBoolean

Writes an element with the local name specified as a string and a [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementBoolean(string localName, bool value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `value` | `bool` | [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to write `true` as the content of the element; [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to write `false`. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementBoolean

Writes an element with the local name specified as a read-only span of characters and a [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)
value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementBoolean(System.ReadOnlySpan<char> localName, bool value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `value` | `bool` | [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to write `true` as the content of the element; [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to write `false`. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementBoolean

Writes an element with the local name specified as a read-only span of UTF-8 bytes and a [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)
value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementBoolean(System.ReadOnlySpan<byte> utf8LocalName, bool value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `value` | `bool` | [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to write `true` as the content of the element; [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to write `false`. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementBoolean

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and a [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementBoolean(CloudNimble.Text.Xml.XmlEncodedText localName, bool value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `value` | `bool` | [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to write `true` as the content of the element; [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to write `false`. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a string and an [Int32](https://learn.microsoft.com/dotnet/api/system.int32) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(string localName, int value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `value` | `int` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a string and a [Int64](https://learn.microsoft.com/dotnet/api/system.int64) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(string localName, long value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `value` | `long` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a string and a [Double](https://learn.microsoft.com/dotnet/api/system.double) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(string localName, double value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `value` | `double` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Not-a-number is written as `NaN`, positive infinity as `INF`, and negative infinity as `-INF`.

### &#x20;WriteElementNumber

Writes an element with the local name specified as a string and a [Single](https://learn.microsoft.com/dotnet/api/system.single) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(string localName, float value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `value` | `float` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Not-a-number is written as `NaN`, positive infinity as `INF`, and negative infinity as `-INF`.

### &#x20;WriteElementNumber

Writes an element with the local name specified as a string and a [Decimal](https://learn.microsoft.com/dotnet/api/system.decimal) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(string localName, decimal value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `value` | `decimal` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a string and a [UInt32](https://learn.microsoft.com/dotnet/api/system.uint32) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(string localName, uint value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `value` | `uint` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a string and a [UInt64](https://learn.microsoft.com/dotnet/api/system.uint64) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(string localName, ulong value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `value` | `ulong` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of characters and an [Int32](https://learn.microsoft.com/dotnet/api/system.int32) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<char> localName, int value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `value` | `int` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of characters and a [Int64](https://learn.microsoft.com/dotnet/api/system.int64) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<char> localName, long value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `value` | `long` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of characters and a [Double](https://learn.microsoft.com/dotnet/api/system.double) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<char> localName, double value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `value` | `double` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Not-a-number is written as `NaN`, positive infinity as `INF`, and negative infinity as `-INF`.

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of characters and a [Single](https://learn.microsoft.com/dotnet/api/system.single) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<char> localName, float value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `value` | `float` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Not-a-number is written as `NaN`, positive infinity as `INF`, and negative infinity as `-INF`.

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of characters and a [Decimal](https://learn.microsoft.com/dotnet/api/system.decimal) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<char> localName, decimal value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `value` | `decimal` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of characters and a [UInt32](https://learn.microsoft.com/dotnet/api/system.uint32) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<char> localName, uint value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `value` | `uint` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of characters and a [UInt64](https://learn.microsoft.com/dotnet/api/system.uint64) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<char> localName, ulong value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `value` | `ulong` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of UTF-8 bytes and an [Int32](https://learn.microsoft.com/dotnet/api/system.int32) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<byte> utf8LocalName, int value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `value` | `int` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of UTF-8 bytes and a [Int64](https://learn.microsoft.com/dotnet/api/system.int64) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<byte> utf8LocalName, long value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `value` | `long` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of UTF-8 bytes and a [Double](https://learn.microsoft.com/dotnet/api/system.double) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<byte> utf8LocalName, double value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `value` | `double` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Not-a-number is written as `NaN`, positive infinity as `INF`, and negative infinity as `-INF`.

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of UTF-8 bytes and a [Single](https://learn.microsoft.com/dotnet/api/system.single) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<byte> utf8LocalName, float value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `value` | `float` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Not-a-number is written as `NaN`, positive infinity as `INF`, and negative infinity as `-INF`.

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of UTF-8 bytes and a [Decimal](https://learn.microsoft.com/dotnet/api/system.decimal) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<byte> utf8LocalName, decimal value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `value` | `decimal` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of UTF-8 bytes and a [UInt32](https://learn.microsoft.com/dotnet/api/system.uint32) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<byte> utf8LocalName, uint value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `value` | `uint` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a read-only span of UTF-8 bytes and a [UInt64](https://learn.microsoft.com/dotnet/api/system.uint64) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(System.ReadOnlySpan<byte> utf8LocalName, ulong value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `value` | `ulong` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and an [Int32](https://learn.microsoft.com/dotnet/api/system.int32) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(CloudNimble.Text.Xml.XmlEncodedText localName, int value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `value` | `int` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and a [Int64](https://learn.microsoft.com/dotnet/api/system.int64) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(CloudNimble.Text.Xml.XmlEncodedText localName, long value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `value` | `long` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and a [Double](https://learn.microsoft.com/dotnet/api/system.double) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(CloudNimble.Text.Xml.XmlEncodedText localName, double value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `value` | `double` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Not-a-number is written as `NaN`, positive infinity as `INF`, and negative infinity as `-INF`.

### &#x20;WriteElementNumber

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and a [Single](https://learn.microsoft.com/dotnet/api/system.single) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(CloudNimble.Text.Xml.XmlEncodedText localName, float value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `value` | `float` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Not-a-number is written as `NaN`, positive infinity as `INF`, and negative infinity as `-INF`.

### &#x20;WriteElementNumber

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and a [Decimal](https://learn.microsoft.com/dotnet/api/system.decimal) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(CloudNimble.Text.Xml.XmlEncodedText localName, decimal value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `value` | `decimal` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and a [UInt32](https://learn.microsoft.com/dotnet/api/system.uint32) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(CloudNimble.Text.Xml.XmlEncodedText localName, uint value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `value` | `uint` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementNumber

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and a [UInt64](https://learn.microsoft.com/dotnet/api/system.uint64) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementNumber(CloudNimble.Text.Xml.XmlEncodedText localName, ulong value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `value` | `ulong` | The number to write as the content of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a string and a string value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(string localName, string value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `value` | `string?` | The text to write as the content of the element, escaped as needed, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to write an empty element. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *value* contains a character that XML does not allow. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name and the namespace URI specified as strings and a string value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(string localName, string namespaceUri, string value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `namespaceUri` | `string?` | The namespace URI of the element. An empty string means no namespace. [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) leaves the namespace unstated, so the element is written as named and inherits the default namespace in scope. |
| `value` | `string?` | The text to write as the content of the element, escaped as needed, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to write an empty element. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *value* contains a character that XML does not allow. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The namespace is handled as it is by [Utf8XmlWriter.WriteStartElement](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestartelement).

### &#x20;WriteElementString

Writes an element with the local name specified as a string and a [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(string localName, System.DateTime value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `value` | `System.DateTime` | The value to write as an XML Schema `dateTime`. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The value is formatted as it is by [Utf8XmlWriter.WriteStringValue](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestringvalue).

### &#x20;WriteElementString

Writes an element with the local name specified as a string and a [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(string localName, System.DateTimeOffset value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `value` | `System.DateTimeOffset` | The value to write as an XML Schema `dateTime` with its offset. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a string and a [Guid](https://learn.microsoft.com/dotnet/api/system.guid) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(string localName, System.Guid value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `value` | `System.Guid` | The value to write in the form `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name and the text content specified as read-only spans of characters.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(System.ReadOnlySpan<char> localName, System.ReadOnlySpan<char> value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `value` | `System.ReadOnlySpan<char>` | The text to write as the content of the element, escaped as needed. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *value* contains a character that XML does not allow. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name and the text content specified as read-only spans of UTF-8 bytes.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(System.ReadOnlySpan<byte> utf8LocalName, System.ReadOnlySpan<byte> utf8Value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `utf8Value` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded text to write as the content of the element, escaped as needed. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *utf8Value* is not valid UTF-8, or contains a character that XML does not allow. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a string and text specified as a read-only span of characters as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(string localName, System.ReadOnlySpan<char> value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `value` | `System.ReadOnlySpan<char>` | The text to write as the content of the element, escaped as needed. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *value* contains a character that XML does not allow. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a string and text specified as a read-only span of UTF-8 bytes as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(string localName, System.ReadOnlySpan<byte> utf8Value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `utf8Value` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded text to write as the content of the element, escaped as needed. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *utf8Value* is not valid UTF-8, or contains a character that XML does not allow. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a read-only span of characters and a string value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(System.ReadOnlySpan<char> localName, string value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `value` | `string?` | The text to write as the content of the element, escaped as needed, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to write an empty element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *value* contains a character that XML does not allow. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a read-only span of characters and text specified as a read-only span of UTF-8 bytes as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(System.ReadOnlySpan<char> localName, System.ReadOnlySpan<byte> utf8Value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `utf8Value` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded text to write as the content of the element, escaped as needed. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *utf8Value* is not valid UTF-8, or contains a character that XML does not allow. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a read-only span of characters and a [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(System.ReadOnlySpan<char> localName, System.DateTime value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `value` | `System.DateTime` | The value to write as an XML Schema `dateTime`. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The value is formatted as it is by [Utf8XmlWriter.WriteStringValue](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestringvalue).

### &#x20;WriteElementString

Writes an element with the local name specified as a read-only span of characters and a [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(System.ReadOnlySpan<char> localName, System.DateTimeOffset value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `value` | `System.DateTimeOffset` | The value to write as an XML Schema `dateTime` with its offset. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a read-only span of characters and a [Guid](https://learn.microsoft.com/dotnet/api/system.guid) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(System.ReadOnlySpan<char> localName, System.Guid value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `value` | `System.Guid` | The value to write in the form `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a read-only span of UTF-8 bytes and a string value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(System.ReadOnlySpan<byte> utf8LocalName, string value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `value` | `string?` | The text to write as the content of the element, escaped as needed, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to write an empty element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *value* contains a character that XML does not allow. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a read-only span of UTF-8 bytes and text specified as a read-only span of characters as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(System.ReadOnlySpan<byte> utf8LocalName, System.ReadOnlySpan<char> value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `value` | `System.ReadOnlySpan<char>` | The text to write as the content of the element, escaped as needed. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *value* contains a character that XML does not allow. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a read-only span of UTF-8 bytes and a [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(System.ReadOnlySpan<byte> utf8LocalName, System.DateTime value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `value` | `System.DateTime` | The value to write as an XML Schema `dateTime`. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The value is formatted as it is by [Utf8XmlWriter.WriteStringValue](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestringvalue).

### &#x20;WriteElementString

Writes an element with the local name specified as a read-only span of UTF-8 bytes and a [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(System.ReadOnlySpan<byte> utf8LocalName, System.DateTimeOffset value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `value` | `System.DateTimeOffset` | The value to write as an XML Schema `dateTime` with its offset. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a read-only span of UTF-8 bytes and a [Guid](https://learn.microsoft.com/dotnet/api/system.guid) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(System.ReadOnlySpan<byte> utf8LocalName, System.Guid value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `value` | `System.Guid` | The value to write in the form `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and a string value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(CloudNimble.Text.Xml.XmlEncodedText localName, string value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `value` | `string?` | The text to write as the content of the element, escaped as needed, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to write an empty element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *value* contains a character that XML does not allow. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and text specified as a read-only span of characters as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(CloudNimble.Text.Xml.XmlEncodedText localName, System.ReadOnlySpan<char> value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `value` | `System.ReadOnlySpan<char>` | The text to write as the content of the element, escaped as needed. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *value* contains a character that XML does not allow. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and text specified as a read-only span of UTF-8 bytes as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(CloudNimble.Text.Xml.XmlEncodedText localName, System.ReadOnlySpan<byte> utf8Value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `utf8Value` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded text to write as the content of the element, escaped as needed. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *utf8Value* is not valid UTF-8, or contains a character that XML does not allow. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and a [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(CloudNimble.Text.Xml.XmlEncodedText localName, System.DateTime value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `value` | `System.DateTime` | The value to write as an XML Schema `dateTime`. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The value is formatted as it is by [Utf8XmlWriter.WriteStringValue](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestringvalue).

### &#x20;WriteElementString

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and a [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(CloudNimble.Text.Xml.XmlEncodedText localName, System.DateTimeOffset value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `value` | `System.DateTimeOffset` | The value to write as an XML Schema `dateTime` with its offset. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteElementString

Writes an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md) and a [Guid](https://learn.microsoft.com/dotnet/api/system.guid) value as its content.

#### Syntax

```csharp theme={"dark"}
public void WriteElementString(CloudNimble.Text.Xml.XmlEncodedText localName, System.Guid value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |
| `value` | `System.Guid` | The value to write in the form `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteEmptyElement

Writes an empty element (`<localName/>`) with the local name specified as a string.

#### Syntax

```csharp theme={"dark"}
public void WriteEmptyElement(string localName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteEmptyElement

Writes an empty element with the local name and the namespace URI specified as strings.

#### Syntax

```csharp theme={"dark"}
public void WriteEmptyElement(string localName, string namespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `namespaceUri` | `string?` | The namespace URI of the element. An empty string means no namespace. [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) leaves the namespace unstated, so the element is written as named and inherits the default namespace in scope. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The namespace is handled as it is by [Utf8XmlWriter.WriteStartElement](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestartelement).

### &#x20;WriteEmptyElement

Writes an empty element with the prefix, the local name, and the namespace URI specified as strings.

#### Syntax

```csharp theme={"dark"}
public void WriteEmptyElement(string prefix, string localName, string namespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `prefix` | `string?` | The prefix of the element, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or an empty string for none. |
| `localName` | `string` | The local name of the element. |
| `namespaceUri` | `string?` | The namespace URI of the element. An empty string means no namespace. [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) leaves the namespace unstated, so the element is written as named and inherits the default namespace in scope. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* or *prefix* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *prefix* is `xmlns`, or is a prefix other than `xml` and *namespaceUri* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or empty. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The namespace is handled as it is by [Utf8XmlWriter.WriteStartElement](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestartelement).

### &#x20;WriteEmptyElement

Writes an empty element (`<localName/>`) with the local name specified as a read-only span of characters.

#### Syntax

```csharp theme={"dark"}
public void WriteEmptyElement(System.ReadOnlySpan<char> localName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteEmptyElement

Writes an empty element with the local name and the namespace URI specified as read-only spans of characters.

#### Syntax

```csharp theme={"dark"}
public void WriteEmptyElement(System.ReadOnlySpan<char> localName, System.ReadOnlySpan<char> namespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `namespaceUri` | `System.ReadOnlySpan<char>` | The namespace URI of the element. An empty span means no namespace. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The namespace is handled as it is by [Utf8XmlWriter.WriteStartElement](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestartelement).

### &#x20;WriteEmptyElement

Writes an empty element with the local name specified as a read-only span of UTF-8 bytes.

#### Syntax

```csharp theme={"dark"}
public void WriteEmptyElement(System.ReadOnlySpan<byte> utf8LocalName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteEmptyElement

Writes an empty element with the local name and the namespace URI specified as read-only spans of UTF-8 bytes.

#### Syntax

```csharp theme={"dark"}
public void WriteEmptyElement(System.ReadOnlySpan<byte> utf8LocalName, System.ReadOnlySpan<byte> utf8NamespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `utf8NamespaceUri` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded namespace URI of the element. An empty span means no namespace. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The namespace is handled as it is by [Utf8XmlWriter.WriteStartElement](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestartelement).

### &#x20;WriteEmptyElement

Writes an empty element with the prefix, the local name, and the namespace URI specified as read-only
spans of UTF-8 bytes.

#### Syntax

```csharp theme={"dark"}
public void WriteEmptyElement(System.ReadOnlySpan<byte> utf8Prefix, System.ReadOnlySpan<byte> utf8LocalName, System.ReadOnlySpan<byte> utf8NamespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8Prefix` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded prefix of the element, or an empty span for none. |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `utf8NamespaceUri` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded namespace URI of the element. An empty span means no namespace. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* or *utf8Prefix* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *utf8Prefix* is `xmlns`, or is a prefix other than `xml` and *utf8NamespaceUri* is empty. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The namespace is handled as it is by [Utf8XmlWriter.WriteStartElement](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestartelement).

### &#x20;WriteEmptyElement

Writes an empty element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md).

#### Syntax

```csharp theme={"dark"}
public void WriteEmptyElement(CloudNimble.Text.Xml.XmlEncodedText localName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteEndAttribute

Writes the end of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteEndAttribute()
```

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | No attribute is open. |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteEndElement

Writes the end of the current element.

#### Syntax

```csharp theme={"dark"}
public void WriteEndElement()
```

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | No element is open. |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

An element that has no content is closed as an empty element (`/>`). Any other element gets an
end tag (`</name>`). An attribute that is still open is ended first.

### &#x20;WriteFullEndElement

Writes the end of the current element as a full end tag (`</name>`), even when the element has no content.

#### Syntax

```csharp theme={"dark"}
public void WriteFullEndElement()
```

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | No element is open. |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

An attribute that is still open is ended first.

### &#x20;WriteNamespaceDeclaration

Writes a namespace declaration (`xmlns:prefix="namespaceUri"`) on the start tag of the current
element, with the prefix and the namespace URI specified as strings.

#### Syntax

```csharp theme={"dark"}
public void WriteNamespaceDeclaration(string prefix, string namespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `prefix` | `string` | The prefix to declare, or an empty string to declare the default namespace. |
| `namespaceUri` | `string` | The namespace URI to bind to *prefix*. An empty string removes the binding, which XML 1.0 allows only for the default namespace. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *prefix* or *namespaceUri* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | No start tag is open, or an attribute is still open. |
| -or- | |
| *prefix* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). | |
| -or- | |
| The declaration is not allowed by Namespaces in XML: it binds the `xml` prefix to another namespace, declares the `xmlns` prefix, binds the `xml` or `xmlns` namespace to another prefix or as the default namespace, or removes the binding of a prefix in an XML 1.0 document. | |
| -or- | |
| The element already declares *prefix*, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The binding is in scope for the element and its descendants. A declaration counts as an attribute
toward [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount).

### &#x20;WriteNamespaceDeclaration

Writes a namespace declaration (`xmlns:prefix="namespaceUri"`) on the start tag of the current
element, with the prefix and the namespace URI specified as read-only spans of UTF-8 bytes.

#### Syntax

```csharp theme={"dark"}
public void WriteNamespaceDeclaration(System.ReadOnlySpan<byte> utf8Prefix, System.ReadOnlySpan<byte> utf8NamespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8Prefix` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded prefix to declare, or an empty span to declare the default namespace. |
| `utf8NamespaceUri` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded namespace URI to bind to *utf8Prefix*. An empty span removes the binding, which XML 1.0 allows only for the default namespace. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | No start tag is open, or an attribute is still open. |
| -or- | |
| *utf8Prefix* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). | |
| -or- | |
| The declaration is not allowed by Namespaces in XML: it binds the `xml` prefix to another namespace, declares the `xmlns` prefix, binds the `xml` or `xmlns` namespace to another prefix or as the default namespace, or removes the binding of a prefix in an XML 1.0 document. | |
| -or- | |
| The element already declares *utf8Prefix*, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The binding is in scope for the element and its descendants. A declaration counts as an attribute
toward [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount).

### &#x20;WriteNilElement

Writes an empty element that has the attribute `xsi:nil="true"`, with the local name specified as a string.

#### Syntax

```csharp theme={"dark"}
public void WriteNilElement(string localName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

If the XML Schema instance namespace ([XmlNamespaces.Xsi](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlNamespaces.md#xsi)) is not in scope, the writer
declares it on the element with the prefix `xsi`.

### &#x20;WriteNilElement

Writes an empty element that has the attribute `xsi:nil="true"`, with the local name and the
namespace URI specified as strings.

#### Syntax

```csharp theme={"dark"}
public void WriteNilElement(string localName, string namespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `namespaceUri` | `string?` | The namespace URI of the element. An empty string means no namespace. [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) leaves the namespace unstated, so the element is written as named and inherits the default namespace in scope. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The namespace is handled as it is by [Utf8XmlWriter.WriteStartElement](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestartelement). If the XML Schema
instance namespace ([XmlNamespaces.Xsi](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlNamespaces.md#xsi)) is not in scope, the writer declares it on the
element with the prefix `xsi`.

### &#x20;WriteNilElement

Writes an empty element that has the attribute `xsi:nil="true"`, with the local name specified as a
read-only span of characters.

#### Syntax

```csharp theme={"dark"}
public void WriteNilElement(System.ReadOnlySpan<char> localName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

If the XML Schema instance namespace ([XmlNamespaces.Xsi](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlNamespaces.md#xsi)) is not in scope, the writer
declares it on the element with the prefix `xsi`.

### &#x20;WriteNilElement

Writes an empty element that has the attribute `xsi:nil="true"`, with the local name specified as a
read-only span of UTF-8 bytes.

#### Syntax

```csharp theme={"dark"}
public void WriteNilElement(System.ReadOnlySpan<byte> utf8LocalName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

If the XML Schema instance namespace ([XmlNamespaces.Xsi](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlNamespaces.md#xsi)) is not in scope, the writer
declares it on the element with the prefix `xsi`.

### &#x20;WriteNilElement

Writes an empty element that has the attribute `xsi:nil="true"`, with the local name specified as a
pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md).

#### Syntax

```csharp theme={"dark"}
public void WriteNilElement(CloudNimble.Text.Xml.XmlEncodedText localName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

If the XML Schema instance namespace ([XmlNamespaces.Xsi](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlNamespaces.md#xsi)) is not in scope, the writer
declares it on the element with the prefix `xsi`.

### &#x20;WriteNilValue

Writes the attribute `xsi:nil="true"` on the start tag of the current element.

#### Syntax

```csharp theme={"dark"}
public void WriteNilValue()
```

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | No start tag is open. |
| -or- | |
| The element already has an `xsi:nil` attribute, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

If the XML Schema instance namespace ([XmlNamespaces.Xsi](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlNamespaces.md#xsi)) is not in scope, the writer first
declares it on the element with the prefix `xsi`.

### &#x20;WriteNumberValue

Writes an [Int32](https://learn.microsoft.com/dotnet/api/system.int32) value to the content of the current element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteNumberValue(int value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `int` | The number to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteNumberValue

Writes a [Int64](https://learn.microsoft.com/dotnet/api/system.int64) value to the content of the current element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteNumberValue(long value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `long` | The number to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteNumberValue

Writes a [Double](https://learn.microsoft.com/dotnet/api/system.double) value to the content of the current element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteNumberValue(double value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `double` | The number to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Not-a-number is written as `NaN`, positive infinity as `INF`, and negative infinity as `-INF`.

### &#x20;WriteNumberValue

Writes a [Single](https://learn.microsoft.com/dotnet/api/system.single) value to the content of the current element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteNumberValue(float value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `float` | The number to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Not-a-number is written as `NaN`, positive infinity as `INF`, and negative infinity as `-INF`.

### &#x20;WriteNumberValue

Writes a [Decimal](https://learn.microsoft.com/dotnet/api/system.decimal) value to the content of the current element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteNumberValue(decimal value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `decimal` | The number to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteNumberValue

Writes a [UInt32](https://learn.microsoft.com/dotnet/api/system.uint32) value to the content of the current element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteNumberValue(uint value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `uint` | The number to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteNumberValue

Writes a [UInt64](https://learn.microsoft.com/dotnet/api/system.uint64) value to the content of the current element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteNumberValue(ulong value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `ulong` | The number to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteProcessingInstruction

Writes a processing instruction (`<?target data?>`) with the target and the data specified as strings.

#### Syntax

```csharp theme={"dark"}
public void WriteProcessingInstruction(string target, string data)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `target` | `string` | The target of the processing instruction. |
| `data` | `string?` | The data of the processing instruction, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or an empty string for none. It is written as it is, without escaping. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *target* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *target* is not a valid XML name without a colon, is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount), or is `xml` in any letter case. |
| -or- | |
| *data* contains `?>`. | |
| -or- | |
| *data* contains a character that XML does not allow. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

A processing instruction can be written inside an element, and before or after the root element.

### &#x20;WriteRawValue

Writes the input as XML content, with the input specified as a read-only span of UTF-8 bytes. The
input is copied to the output without escaping.

#### Syntax

```csharp theme={"dark"}
public void WriteRawValue(System.ReadOnlySpan<byte> utf8Xml, bool skipInputValidation = false)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8Xml` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded XML text to write. |
| `skipInputValidation` | `bool` | [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to copy the input without checking it; [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to check first that the input is well formed in the place where it is written. The default is [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *skipInputValidation* is [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) and the input is not well formed in the place where it is written. |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Unless *skipInputValidation* is [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) or
[XmlWriterOptions.SkipValidation](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#skipvalidation) is set, the writer reads the input before it copies it and
throws if the document would not be well formed: inside an element the input must be element content
that uses only prefixes in scope, in an attribute it must be an attribute value with no quotation
mark, and at the document level it must be comments, processing instructions, white space, and at
most the one root element. Inside an element, the input counts as text of that element, so the
element's end tag is not indented. At the document level, the writer does not write the XML
declaration before the input.

### &#x20;WriteRawValue

Writes the input as XML content, with the input specified as a read-only span of characters. The
input is copied to the output without escaping.

#### Syntax

```csharp theme={"dark"}
public void WriteRawValue(System.ReadOnlySpan<char> xml, bool skipInputValidation = false)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `xml` | `System.ReadOnlySpan<char>` | The XML text to write. |
| `skipInputValidation` | `bool` | [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to copy the input without checking it; [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to check first that the input is well formed in the place where it is written. The default is [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *skipInputValidation* is [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) and the input is not well formed in the place where it is written. |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Unless *skipInputValidation* is [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) or
[XmlWriterOptions.SkipValidation](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#skipvalidation) is set, the writer reads the input before it copies it and
throws if the document would not be well formed: inside an element the input must be element content
that uses only prefixes in scope, in an attribute it must be an attribute value with no quotation
mark, and at the document level it must be comments, processing instructions, white space, and at
most the one root element. Inside an element, the input counts as text of that element, so the
element's end tag is not indented. At the document level, the writer does not write the XML
declaration before the input.

### &#x20;WriteRawValue

Writes the input as XML content, with the input specified as a string. The input is copied to the
output without escaping.

#### Syntax

```csharp theme={"dark"}
public void WriteRawValue(string xml, bool skipInputValidation = false)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `xml` | `string` | The XML text to write. |
| `skipInputValidation` | `bool` | [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to copy the input without checking it; [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to check first that the input is well formed in the place where it is written. The default is [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *skipInputValidation* is [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) and the input is not well formed in the place where it is written. |
| `ArgumentNullException` | *xml* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Unless *skipInputValidation* is [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) or
[XmlWriterOptions.SkipValidation](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#skipvalidation) is set, the writer reads the input before it copies it and
throws if the document would not be well formed: inside an element the input must be element content
that uses only prefixes in scope, in an attribute it must be an attribute value with no quotation
mark, and at the document level it must be comments, processing instructions, white space, and at
most the one root element. Inside an element, the input counts as text of that element, so the
element's end tag is not indented. At the document level, the writer does not write the XML
declaration before the input.

### &#x20;WriteStartAttribute

Writes the beginning of an attribute with the name specified as a string.

#### Syntax

```csharp theme={"dark"}
public void WriteStartAttribute(string name)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `name` | `string` | The name of the attribute, without a prefix. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *name* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | No start tag is open, or another attribute is still open. |
| -or- | |
| *name* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). | |
| -or- | |
| The element already has an attribute with the same name, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |

#### Remarks

Write the value with one or more calls to the value methods, such as [Utf8XmlWriter.WriteStringValue](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestringvalue),
and then call [Utf8XmlWriter.WriteEndAttribute](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writeendattribute).

### &#x20;WriteStartAttribute

Writes the beginning of an attribute with the name specified as a read-only span of characters.

#### Syntax

```csharp theme={"dark"}
public void WriteStartAttribute(System.ReadOnlySpan<char> name)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `name` | `System.ReadOnlySpan<char>` | The name of the attribute, without a prefix. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | No start tag is open, or another attribute is still open. |
| -or- | |
| *name* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). | |
| -or- | |
| The element already has an attribute with the same name, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

Write the value with one or more calls to the value methods, such as [Utf8XmlWriter.WriteStringValue](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestringvalue),
and then call [Utf8XmlWriter.WriteEndAttribute](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writeendattribute).

### &#x20;WriteStartAttribute

Writes the beginning of an attribute with the prefix, the local name, and the namespace URI specified as strings.

#### Syntax

```csharp theme={"dark"}
public void WriteStartAttribute(string prefix, string localName, string namespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `prefix` | `string?` | The prefix of the attribute, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or an empty string for none. |
| `localName` | `string` | The local name of the attribute. |
| `namespaceUri` | `string?` | The namespace URI of the attribute, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or an empty string for none. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | No start tag is open, or another attribute is still open. |
| -or- | |
| *localName* or *prefix* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). | |
| -or- | |
| *prefix* is a prefix other than `xml` and `xmlns`, and *namespaceUri* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or empty. | |
| -or- | |
| The element already has an attribute with the same local name and namespace URI, or already has [XmlWriterOptions.MaxAttributeCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxattributecount) attributes. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

With a prefix, the writer declares *prefix* on the element unless it is already bound to
*namespaceUri*. With a namespace URI and no prefix, the writer uses a prefix that is
already bound to *namespaceUri*, or declares a generated prefix (`ns1`, `ns2`,
and so on) on the element. Write the value with one or more calls to the value methods, such as
[Utf8XmlWriter.WriteStringValue](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestringvalue), and then call [Utf8XmlWriter.WriteEndAttribute](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writeendattribute).

### &#x20;WriteStartElement

Writes the start tag of an element with the local name specified as a string.

#### Syntax

```csharp theme={"dark"}
public void WriteStartElement(string localName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The start tag stays open for attributes and namespace declarations until content or an end tag is written.

### &#x20;WriteStartElement

Writes the start tag of an element with the local name and the namespace URI specified as strings.

#### Syntax

```csharp theme={"dark"}
public void WriteStartElement(string localName, string namespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `string` | The local name of the element. |
| `namespaceUri` | `string?` | The namespace URI of the element. An empty string means no namespace. [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) leaves the namespace unstated, so the element is written as named and inherits the default namespace in scope. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

If *namespaceUri* is the default namespace in scope, the element is written without a
prefix. If it is bound to a prefix that is in scope, the element is written with that prefix. Otherwise,
the writer declares it as the default namespace on the element. For an empty string, that declaration
is `xmlns=""`, and it is written only when a default namespace is in scope.

### &#x20;WriteStartElement

Writes the start tag of an element with the prefix, the local name, and the namespace URI specified as strings.

#### Syntax

```csharp theme={"dark"}
public void WriteStartElement(string prefix, string localName, string namespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `prefix` | `string?` | The prefix of the element, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or an empty string for none. |
| `localName` | `string` | The local name of the element. |
| `namespaceUri` | `string?` | The namespace URI of the element. An empty string means no namespace. [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) leaves the namespace unstated, so the element is written as named and inherits the default namespace in scope. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | *localName* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `XmlException` | *localName* or *prefix* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *prefix* is `xmlns`, or is a prefix other than `xml` and *namespaceUri* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or empty. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The element is written with *prefix*. Unless *prefix* is already bound
to *namespaceUri*, the writer declares it on the element, even when the namespace has
another prefix in scope. Without a prefix, this overload behaves as
[Utf8XmlWriter.WriteStartElement](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestartelement) does.

### &#x20;WriteStartElement

Writes the start tag of an element with the local name specified as a read-only span of characters.

#### Syntax

```csharp theme={"dark"}
public void WriteStartElement(System.ReadOnlySpan<char> localName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteStartElement

Writes the start tag of an element with the local name specified as a read-only span of UTF-8 bytes.

#### Syntax

```csharp theme={"dark"}
public void WriteStartElement(System.ReadOnlySpan<byte> utf8LocalName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteStartElement

Writes the start tag of an element with the local name specified as a pre-encoded [XmlEncodedText](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlEncodedText.md).

#### Syntax

```csharp theme={"dark"}
public void WriteStartElement(CloudNimble.Text.Xml.XmlEncodedText localName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `CloudNimble.Text.Xml.XmlEncodedText` | The UTF-8 encoded local name of the element. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteStartElement

Writes the start tag of an element with the local name and the namespace URI specified as read-only
spans of characters.

#### Syntax

```csharp theme={"dark"}
public void WriteStartElement(System.ReadOnlySpan<char> localName, System.ReadOnlySpan<char> namespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `localName` | `System.ReadOnlySpan<char>` | The local name of the element. |
| `namespaceUri` | `System.ReadOnlySpan<char>` | The namespace URI of the element. An empty span means no namespace. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *localName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The namespace is handled as it is by [Utf8XmlWriter.WriteStartElement](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestartelement).

### &#x20;WriteStartElement

Writes the start tag of an element with the local name and the namespace URI specified as read-only
spans of UTF-8 bytes.

#### Syntax

```csharp theme={"dark"}
public void WriteStartElement(System.ReadOnlySpan<byte> utf8LocalName, System.ReadOnlySpan<byte> utf8NamespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `utf8NamespaceUri` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded namespace URI of the element. An empty span means no namespace. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The namespace is handled as it is by [Utf8XmlWriter.WriteStartElement](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestartelement).

### &#x20;WriteStartElement

Writes the start tag of an element with the prefix, the local name, and the namespace URI specified as
read-only spans of UTF-8 bytes.

#### Syntax

```csharp theme={"dark"}
public void WriteStartElement(System.ReadOnlySpan<byte> utf8Prefix, System.ReadOnlySpan<byte> utf8LocalName, System.ReadOnlySpan<byte> utf8NamespaceUri)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8Prefix` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded prefix of the element, or an empty span for none. |
| `utf8LocalName` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded local name of the element. |
| `utf8NamespaceUri` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded namespace URI of the element. An empty span means no namespace. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | *utf8LocalName* or *utf8Prefix* is not a valid XML name without a colon, or is longer than [XmlWriterOptions.MaxNameByteCount](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxnamebytecount). |
| -or- | |
| *utf8Prefix* is `xmlns`, or is a prefix other than `xml` and *utf8NamespaceUri* is empty. | |
| -or- | |
| The document already has a root element. | |
| -or- | |
| The element is nested deeper than [XmlWriterOptions.MaxDepth](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#maxdepth). | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The namespace is handled as it is by [Utf8XmlWriter.WriteStartElement](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestartelement).

### &#x20;WriteStringValue

Writes text specified as a string to the content of the current element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteStringValue(string value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `string?` | The text to write, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to write nothing. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| -or- | |
| *value* contains a character that XML does not allow. | |

#### Remarks

The text is escaped as needed: `&` and `<` become entity references, and a character
that would not survive a round trip (such as a carriage return, or a tab or line feed in an attribute
value) becomes a character reference.

### &#x20;WriteStringValue

Writes text specified as a read-only span of characters to the content of the current element or to the
value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteStringValue(System.ReadOnlySpan<char> value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `System.ReadOnlySpan<char>` | The text to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| -or- | |
| *value* contains a character that XML does not allow. | |

#### Remarks

The text is escaped as it is by [Utf8XmlWriter.WriteStringValue](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestringvalue).

### &#x20;WriteStringValue

Writes text specified as a read-only span of UTF-8 bytes to the content of the current element or to the
value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteStringValue(System.ReadOnlySpan<byte> utf8Value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `utf8Value` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded text to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| -or- | |
| *utf8Value* is not valid UTF-8, or contains a character that XML does not allow. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The text is escaped as it is by [Utf8XmlWriter.WriteStringValue](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestringvalue).

### &#x20;WriteStringValue

Writes a [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) value as an XML Schema `dateTime` to the content of the current
element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteStringValue(System.DateTime value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `System.DateTime` | The value to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

A value whose [Kind](https://learn.microsoft.com/dotnet/api/system.datetime.kind) is [Utc](https://learn.microsoft.com/dotnet/api/system.datetimekind.utc) ends with `Z`. A
[Local](https://learn.microsoft.com/dotnet/api/system.datetimekind.local) value ends with the offset of the local time zone. A
[Unspecified](https://learn.microsoft.com/dotnet/api/system.datetimekind.unspecified) value has no time zone.

### &#x20;WriteStringValue

Writes a [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset) value as an XML Schema `dateTime` with its offset to the
content of the current element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteStringValue(System.DateTimeOffset value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `System.DateTimeOffset` | The value to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteStringValue

Writes a [DateOnly](https://learn.microsoft.com/dotnet/api/system.dateonly) value as an XML Schema `date` to the content of the current element
or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteStringValue(System.DateOnly value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `System.DateOnly` | The value to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteStringValue

Writes a [TimeOnly](https://learn.microsoft.com/dotnet/api/system.timeonly) value as an XML Schema `time` to the content of the current element
or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteStringValue(System.TimeOnly value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `System.TimeOnly` | The value to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteStringValue

Writes a [TimeSpan](https://learn.microsoft.com/dotnet/api/system.timespan) value as an XML Schema `duration` to the content of the current
element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteStringValue(System.TimeSpan value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `System.TimeSpan` | The value to write. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteStringValue

Writes a [Guid](https://learn.microsoft.com/dotnet/api/system.guid) value to the content of the current element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteStringValue(System.Guid value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `System.Guid` | The value to write in the form `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| `ObjectDisposedException` | This instance has been disposed. |

### &#x20;WriteStringValueSegment

Writes a segment of text specified as a read-only span of UTF-8 bytes to the content of the current
element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteStringValueSegment(System.ReadOnlySpan<byte> value, bool isFinalSegment)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `System.ReadOnlySpan<byte>` | The UTF-8 encoded segment of the text to write. |
| `isFinalSegment` | `bool` | [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to indicate that this is the final segment of the text; otherwise, [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| -or- | |
| The text is not valid UTF-8, or contains a character that XML does not allow. | |
| -or- | |
| A value of another kind is being written in segments. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Examples

```csharp theme={"dark"}
writer.WriteStartElement("note");
writer.WriteStringValueSegment(firstBlock, isFinalSegment: false);
writer.WriteStringValueSegment(lastBlock, isFinalSegment: true);
writer.WriteEndElement();
```

#### Remarks

The segments together are written as [Utf8XmlWriter.WriteStringValue](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestringvalue) writes the whole
text. A segment can end in the middle of a multi-byte character: the writer keeps the bytes of the
incomplete character and writes it when the next segment completes it. After a segment that is not
final, the next call on the writer must be the next segment, apart from [Utf8XmlWriter.Flush](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#flush) and
[Utf8XmlWriter.FlushAsync](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#flushasync); any other call throws an [XmlException](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlException.md).

### &#x20;WriteStringValueSegment

Writes a segment of text specified as a read-only span of characters to the content of the current
element or to the value of the current attribute.

#### Syntax

```csharp theme={"dark"}
public void WriteStringValueSegment(System.ReadOnlySpan<char> value, bool isFinalSegment)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `value` | `System.ReadOnlySpan<char>` | The segment of the text to write. |
| `isFinalSegment` | `bool` | [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to indicate that this is the final segment of the text; otherwise, [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). |

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer is not inside an element or an attribute. |
| -or- | |
| The text contains a character that XML does not allow. | |
| -or- | |
| A value of another kind is being written in segments. | |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The segments together are written as [Utf8XmlWriter.WriteStringValue](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#writestringvalue) writes the whole
text. A segment can end between the two halves of a surrogate pair: the writer keeps the first half
and writes the character when the next segment brings the second. After a segment that is not final,
the next call on the writer must be the next segment, apart from [Utf8XmlWriter.Flush](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#flush) and
[Utf8XmlWriter.FlushAsync](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlWriter.md#flushasync); any other call throws an [XmlException](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlException.md).

### &#x20;WriteXmlDeclaration

Writes the XML declaration (`<?xml version="1.0" encoding="utf-8"?>`).

#### Syntax

```csharp theme={"dark"}
public void WriteXmlDeclaration()
```

#### Exceptions

| Exception | Description |
| - | - |
| `XmlException` | The writer has already written output for this document. |
| `ObjectDisposedException` | This instance has been disposed. |

#### Remarks

The declaration carries the version from [XmlWriterOptions.Version](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#version), the encoding `utf-8`,
and the `standalone` pseudo-attribute when [XmlWriterOptions.Standalone](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#standalone) is set. A byte
order mark comes first when [XmlWriterOptions.EmitByteOrderMark](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#emitbyteordermark) is [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool).
The writer writes the declaration by itself before the first element, comment, or processing
instruction unless [XmlWriterOptions.OmitXmlDeclaration](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlWriterOptions.md#omitxmldeclaration) is [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool).
Call this method to write the declaration even when that option is [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool).

## Related APIs

* CloudNimble.Text.Xml.XmlWriterOptions
* CloudNimble.Text.Xml.XmlEncodedText
* CloudNimble.Text.Xml.XmlVersion
* CloudNimble.Text.Xml.XmlException
* CloudNimble.Text.Xml.XmlNamespaces
* CloudNimble.Text.Xml.Utf8XmlReader
* CloudNimble.Text.Xml.XmlDocument
* CloudNimble.Text.Xml.Serialization.XmlConverter


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