CharacterData Class

https://dom.spec.whatwg.org/#interface-characterdata

public abstract class CharacterData : Node, IChildNode, INonDocumentTypeChildNode
Inheritance
Node CharacterData
Implements

Properties

NameDescription
DataGets or sets the text data of the node.
LengthGets the length of the data, in UTF-16 code units.
NextElementSiblingGets the closest following sibling that is an element, or null when there is none.
NodeValueGets or sets the text data of the node.
PreviousElementSiblingGets the closest preceding sibling that is an element, or null when there is none.
TextContentGets or sets the text data of the node.

Gets or sets the text data of the node.

public string Data { get; set; }

Gets the length of the data, in UTF-16 code units.

public uint Length { get; }

NextElementSibling

Mixins.Members.cs

Gets the closest following sibling that is an element, or null when there is none.

public Element? NextElementSibling { get; }

Gets or sets the text data of the node.

public override string? NodeValue { get; set; }

Property value

string?

PreviousElementSibling

Mixins.Members.cs

Gets the closest preceding sibling that is an element, or null when there is none.

public Element? PreviousElementSibling { get; }

TextContent

CharacterData.cs

Gets or sets the text data of the node.

public override string? TextContent { get; set; }

Property value

string?

Methods

NameDescription
After(ReadOnlySpan<NodeOrString>)Inserts the nodes just after this node, converting the strings into text nodes.
AfterHtml(string, SetHtmlOptions?)Parses the HTML and inserts the result after this node.
AfterHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)Parses the HTML and inserts the result after this node, without the default sanitizer.
AfterHtmlUnsafe(string, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)Parses the HTML and inserts the result after this node, without the default sanitizer.
AppendData(string)Appends the given string to the data.
Before(ReadOnlySpan<NodeOrString>)Inserts the nodes just before this node, converting the strings into text nodes.
BeforeHtml(string, SetHtmlOptions?)Parses the HTML and inserts the result before this node.
BeforeHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)Parses the HTML and inserts the result before this node, without the default sanitizer.
BeforeHtmlUnsafe(string, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)Parses the HTML and inserts the result before this node, without the default sanitizer.
DeleteData(uint, uint)Removes the given number of code units from the data, starting at the given offset.
InsertData(uint, string)Inserts the given string in the data at the given offset.
Remove()Removes this node from its parent, if any.
ReplaceData(uint, uint, string)https://dom.spec.whatwg.org/#concept-cd-replace
ReplaceWith(ReadOnlySpan<NodeOrString>)Replaces this node with the given nodes in its parent, converting the strings into text nodes.
ReplaceWithHtml(string, SetHtmlOptions?)Parses the HTML and replaces this node with the result.
ReplaceWithHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)Parses the HTML and replaces this node with the result, without the default sanitizer.
ReplaceWithHtmlUnsafe(string, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)Parses the HTML and replaces this node with the result, without the default sanitizer.
StreamAfterHtml(SetHtmlOptions?)Returns a writer that parses HTML and inserts the result after this node as it is parsed (proposed by https://github.com/whatwg/html/pull/12758).
StreamAfterHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)Returns a writer that parses HTML and inserts the result after this node as it is parsed, without the default sanitizer (proposed by https://github.com/whatwg/html/pull/12758).
StreamBeforeHtml(SetHtmlOptions?)Returns a writer that parses HTML and inserts the result before this node as it is parsed (proposed by https://github.com/whatwg/html/pull/12758).
StreamBeforeHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)Returns a writer that parses HTML and inserts the result before this node as it is parsed, without the default sanitizer (proposed by https://github.com/whatwg/html/pull/12758).
StreamReplaceWithHtml(SetHtmlOptions?)Returns a writer that parses HTML and replaces this node with the result as it is parsed (proposed by https://github.com/whatwg/html/pull/12758).
StreamReplaceWithHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)Returns a writer that parses HTML and replaces this node with the result as it is parsed, without the default sanitizer (proposed by https://github.com/whatwg/html/pull/12758).
SubstringData(uint, uint)https://dom.spec.whatwg.org/#concept-cd-substring

After(ReadOnlySpan<NodeOrString>)

Mixins.Members.cs

Inserts the nodes just after this node, converting the strings into text nodes.

public void After(params scoped ReadOnlySpan<NodeOrString> nodes)

AfterHtml(string, SetHtmlOptions?)

DynamicMarkup.Insertion.cs

Parses the HTML and inserts the result after this node.

public void AfterHtml(string html, SetHtmlOptions? options = null)

AfterHtmlUnsafe overloads

AfterHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)

DynamicMarkup.Insertion.cs

Parses the HTML and inserts the result after this node, without the default sanitizer.

public void AfterHtmlUnsafe(TrustedHtml html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)

AfterHtmlUnsafe(string, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)

DynamicMarkup.Insertion.cs

Parses the HTML and inserts the result after this node, without the default sanitizer.

public void AfterHtmlUnsafe(string html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)

AppendData(string)

CharacterData.cs

Appends the given string to the data.

public void AppendData(string data)

Before(ReadOnlySpan<NodeOrString>)

Mixins.Members.cs

Inserts the nodes just before this node, converting the strings into text nodes.

public void Before(params scoped ReadOnlySpan<NodeOrString> nodes)

BeforeHtml(string, SetHtmlOptions?)

DynamicMarkup.Insertion.cs

Parses the HTML and inserts the result before this node.

public void BeforeHtml(string html, SetHtmlOptions? options = null)

BeforeHtmlUnsafe overloads

BeforeHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)

DynamicMarkup.Insertion.cs

Parses the HTML and inserts the result before this node, without the default sanitizer.

public void BeforeHtmlUnsafe(TrustedHtml html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)

BeforeHtmlUnsafe(string, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)

DynamicMarkup.Insertion.cs

Parses the HTML and inserts the result before this node, without the default sanitizer.

public void BeforeHtmlUnsafe(string html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)

DeleteData(uint, uint)

CharacterData.cs

Removes the given number of code units from the data, starting at the given offset.

public void DeleteData(uint offset, uint count)

InsertData(uint, string)

CharacterData.cs

Inserts the given string in the data at the given offset.

public void InsertData(uint offset, string data)

Removes this node from its parent, if any.

public void Remove()

ReplaceData(uint, uint, string)

CharacterData.cs

https://dom.spec.whatwg.org/#concept-cd-replace

public void ReplaceData(uint offset, uint count, string data)

ReplaceWith(ReadOnlySpan<NodeOrString>)

Mixins.Members.cs

Replaces this node with the given nodes in its parent, converting the strings into text nodes.

public void ReplaceWith(params scoped ReadOnlySpan<NodeOrString> nodes)

ReplaceWithHtml(string, SetHtmlOptions?)

DynamicMarkup.Insertion.cs

Parses the HTML and replaces this node with the result.

public void ReplaceWithHtml(string html, SetHtmlOptions? options = null)

ReplaceWithHtmlUnsafe overloads

ReplaceWithHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)

DynamicMarkup.Insertion.cs

Parses the HTML and replaces this node with the result, without the default sanitizer.

public void ReplaceWithHtmlUnsafe(TrustedHtml html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)

ReplaceWithHtmlUnsafe(string, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)

DynamicMarkup.Insertion.cs

Parses the HTML and replaces this node with the result, without the default sanitizer.

public void ReplaceWithHtmlUnsafe(string html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)

StreamAfterHtml(SetHtmlOptions?)

DynamicMarkup.Streaming.cs
  • Experimental (WEBPLATEXP0002)

Returns a writer that parses HTML and inserts the result after this node as it is parsed (proposed by https://github.com/whatwg/html/pull/12758).

[Experimental("WEBPLATEXP0002", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public HtmlStreamWriter StreamAfterHtml(SetHtmlOptions? options = null)

Parameters

options SetHtmlOptions?

Returns

HtmlStreamWriter

StreamAfterHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)

DynamicMarkup.Streaming.cs
  • Experimental (WEBPLATEXP0002)

Returns a writer that parses HTML and inserts the result after this node as it is parsed, without the default sanitizer (proposed by https://github.com/whatwg/html/pull/12758).

[Experimental("WEBPLATEXP0002", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public HtmlStreamWriter StreamAfterHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)

Parameters

options SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?

Returns

HtmlStreamWriter

Exceptions

TypeErrorException
Trusted Types are enforced, the options are not TrustedHtmlParserOptions and the default policy did not create them.

StreamBeforeHtml(SetHtmlOptions?)

DynamicMarkup.Streaming.cs
  • Experimental (WEBPLATEXP0002)

Returns a writer that parses HTML and inserts the result before this node as it is parsed (proposed by https://github.com/whatwg/html/pull/12758).

[Experimental("WEBPLATEXP0002", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public HtmlStreamWriter StreamBeforeHtml(SetHtmlOptions? options = null)

Parameters

options SetHtmlOptions?

Returns

HtmlStreamWriter

StreamBeforeHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)

DynamicMarkup.Streaming.cs
  • Experimental (WEBPLATEXP0002)

Returns a writer that parses HTML and inserts the result before this node as it is parsed, without the default sanitizer (proposed by https://github.com/whatwg/html/pull/12758).

[Experimental("WEBPLATEXP0002", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public HtmlStreamWriter StreamBeforeHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)

Parameters

options SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?

Returns

HtmlStreamWriter

Exceptions

TypeErrorException
Trusted Types are enforced, the options are not TrustedHtmlParserOptions and the default policy did not create them.

StreamReplaceWithHtml(SetHtmlOptions?)

DynamicMarkup.Streaming.cs
  • Experimental (WEBPLATEXP0002)

Returns a writer that parses HTML and replaces this node with the result as it is parsed (proposed by https://github.com/whatwg/html/pull/12758).

[Experimental("WEBPLATEXP0002", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public HtmlStreamWriter StreamReplaceWithHtml(SetHtmlOptions? options = null)

Parameters

options SetHtmlOptions?

Returns

HtmlStreamWriter

StreamReplaceWithHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)

DynamicMarkup.Streaming.cs
  • Experimental (WEBPLATEXP0002)

Returns a writer that parses HTML and replaces this node with the result as it is parsed, without the default sanitizer (proposed by https://github.com/whatwg/html/pull/12758).

[Experimental("WEBPLATEXP0002", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public HtmlStreamWriter StreamReplaceWithHtmlUnsafe(SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)

Parameters

options SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?

Returns

HtmlStreamWriter

Exceptions

TypeErrorException
Trusted Types are enforced, the options are not TrustedHtmlParserOptions and the default policy did not create them.

SubstringData(uint, uint)

CharacterData.cs

https://dom.spec.whatwg.org/#concept-cd-substring

public string SubstringData(uint offset, uint count)