CharacterData Class
https://dom.spec.whatwg.org/#interface-characterdata
public abstract class CharacterData : Node, IChildNode, INonDocumentTypeChildNode- Inheritance
NodeCharacterData- Implements
Properties
| Name | Description |
|---|---|
| Data | Gets or sets the text data of the node. |
| Length | Gets the length of the data, in UTF-16 code units. |
| NextElementSibling | Gets the closest following sibling that is an element, or null when there is none. |
| NodeValue | Gets or sets the text data of the node. |
| PreviousElementSibling | Gets the closest preceding sibling that is an element, or null when there is none. |
| TextContent | Gets or sets the text data of the node. |
Data
CharacterData.csGets or sets the text data of the node.
public string Data { get; set; }Length
CharacterData.csGets the length of the data, in UTF-16 code units.
public uint Length { get; }NextElementSibling
Mixins.Members.csGets the closest following sibling that is an element, or null when there is none.
public Element? NextElementSibling { get; }Property value
See also
NodeValue
CharacterData.csPreviousElementSibling
Mixins.Members.csGets the closest preceding sibling that is an element, or null when there is none.
public Element? PreviousElementSibling { get; }Property value
See also
TextContent
CharacterData.csMethods
| Name | Description |
|---|---|
| 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.csInserts 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.csParses the HTML and inserts the result after this node.
public void AfterHtml(string html, SetHtmlOptions? options = null)AfterHtmlUnsafe overloads
AfterHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)
DynamicMarkup.Insertion.csParses 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.csParses the HTML and inserts the result after this node, without the default sanitizer.
public void AfterHtmlUnsafe(string html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)Parameters
Exceptions
TypeErrorException- Trusted Types are enforced and the options or the value are not trusted.
See also
AppendData(string)
CharacterData.csAppends the given string to the data.
Before(ReadOnlySpan<NodeOrString>)
Mixins.Members.csInserts 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.csParses the HTML and inserts the result before this node.
public void BeforeHtml(string html, SetHtmlOptions? options = null)BeforeHtmlUnsafe overloads
BeforeHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)
DynamicMarkup.Insertion.csParses 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.csParses the HTML and inserts the result before this node, without the default sanitizer.
public void BeforeHtmlUnsafe(string html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)Parameters
Exceptions
TypeErrorException- Trusted Types are enforced and the options or the value are not trusted.
See also
DeleteData(uint, uint)
CharacterData.csInsertData(uint, string)
CharacterData.csRemove()
Mixins.Members.csRemoves this node from its parent, if any.
public void Remove()ReplaceData(uint, uint, string)
CharacterData.csReplaceWith(ReadOnlySpan<NodeOrString>)
Mixins.Members.csReplaces this node with the given nodes in its parent, converting the strings into text nodes.
public void ReplaceWith(params scoped ReadOnlySpan<NodeOrString> nodes)Parameters
See also
ReplaceWithHtml(string, SetHtmlOptions?)
DynamicMarkup.Insertion.csParses the HTML and replaces this node with the result.
public void ReplaceWithHtml(string html, SetHtmlOptions? options = null)ReplaceWithHtmlUnsafe overloads
ReplaceWithHtmlUnsafe(TrustedHtml, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions?)
DynamicMarkup.Insertion.csParses 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.csParses the HTML and replaces this node with the result, without the default sanitizer.
public void ReplaceWithHtmlUnsafe(string html, SetHtmlUnsafeOptionsOrTrustedHtmlParserOptions? options = null)Parameters
Exceptions
TypeErrorException- Trusted Types are enforced and the options or the value are not trusted.
See also
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)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
Returns
Exceptions
TypeErrorException- Trusted Types are enforced, the options are not
TrustedHtmlParserOptionsand 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)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
Returns
Exceptions
TypeErrorException- Trusted Types are enforced, the options are not
TrustedHtmlParserOptionsand 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)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
Returns
Exceptions
TypeErrorException- Trusted Types are enforced, the options are not
TrustedHtmlParserOptionsand the default policy did not create them.