# HtmlNode

An owned node. Parsed snapshots are read-only; edits operate on an independent mutable clone.

Class 

`OfficeIMO.Html.Dom`

**Namespace**

`OfficeIMO.Html.Dom`

**Assembly**

`OfficeIMO.Html.Core`

**Source revision**

`ba882f6b0d07` with working tree changes

**Source**

[HtmlNode.cs:74](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L74)

An owned node. Parsed snapshots are read-only; edits operate on an independent mutable clone.

## Inheritance

- object
- HtmlNode

## Derived Types

- [HtmlDocument](/api/html-core/officeimo-html-dom-htmldocument/)
- [HtmlDocumentFragment](/api/html-core/officeimo-html-dom-htmldocumentfragment/)
- [HtmlDocumentType](/api/html-core/officeimo-html-dom-htmldocumenttype/)
- [HtmlElement](/api/html-core/officeimo-html-dom-htmlelement/)

## Usage

Explore 48 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Returned or exposed by 39

- Method [HtmlDocument.AppendChild](/api/html-core/officeimo-html-dom-htmldocument/#method-appendchild-htmlnode)
- Method [HtmlDocument.CreateComment](/api/html-core/officeimo-html-dom-htmldocument/#method-createcomment-string)
- Method [HtmlDocument.CreateTextNode](/api/html-core/officeimo-html-dom-htmldocument/#method-createtextnode-string)
- Method [HtmlDocument.Descendants](/api/html-core/officeimo-html-dom-htmldocument/#method-descendants)
- Method [HtmlDocument.GetNode](/api/html-core/officeimo-html-dom-htmldocument/#method-getnode-int32)
- Method [HtmlDocument.ImportNode](/api/html-core/officeimo-html-dom-htmldocument/#method-importnode-officeimo-html-dom-htmlnode-boolean-threading-cancellationtoken)
- Property [HtmlDocument.ChildNodes](/api/html-core/officeimo-html-dom-htmldocument/#property-childnodes)
- Property [HtmlDocument.FirstChild](/api/html-core/officeimo-html-dom-htmldocument/#property-firstchild)
- Property [HtmlDocument.NextSibling](/api/html-core/officeimo-html-dom-htmldocument/#property-nextsibling)
- Property [HtmlDocument.Parent](/api/html-core/officeimo-html-dom-htmldocument/#property-parent)
- Property [HtmlDocument.PreviousSibling](/api/html-core/officeimo-html-dom-htmldocument/#property-previoussibling)
- Method [HtmlDocumentFragment.AppendChild](/api/html-core/officeimo-html-dom-htmldocumentfragment/#method-appendchild-htmlnode)
- Method [HtmlDocumentFragment.Descendants](/api/html-core/officeimo-html-dom-htmldocumentfragment/#method-descendants)
- Property [HtmlDocumentFragment.ChildNodes](/api/html-core/officeimo-html-dom-htmldocumentfragment/#property-childnodes)
- Property [HtmlDocumentFragment.FirstChild](/api/html-core/officeimo-html-dom-htmldocumentfragment/#property-firstchild)
- Property [HtmlDocumentFragment.NextSibling](/api/html-core/officeimo-html-dom-htmldocumentfragment/#property-nextsibling)
- Property [HtmlDocumentFragment.Parent](/api/html-core/officeimo-html-dom-htmldocumentfragment/#property-parent)
- Property [HtmlDocumentFragment.PreviousSibling](/api/html-core/officeimo-html-dom-htmldocumentfragment/#property-previoussibling)
- Method [HtmlDocumentType.AppendChild](/api/html-core/officeimo-html-dom-htmldocumenttype/#method-appendchild-htmlnode)
- Method [HtmlDocumentType.Descendants](/api/html-core/officeimo-html-dom-htmldocumenttype/#method-descendants)
- Property [HtmlDocumentType.ChildNodes](/api/html-core/officeimo-html-dom-htmldocumenttype/#property-childnodes)
- Property [HtmlDocumentType.FirstChild](/api/html-core/officeimo-html-dom-htmldocumenttype/#property-firstchild)
- Property [HtmlDocumentType.NextSibling](/api/html-core/officeimo-html-dom-htmldocumenttype/#property-nextsibling)
- Property [HtmlDocumentType.Parent](/api/html-core/officeimo-html-dom-htmldocumenttype/#property-parent)
- Property [HtmlDocumentType.PreviousSibling](/api/html-core/officeimo-html-dom-htmldocumenttype/#property-previoussibling)
- Method [HtmlElement.AppendChild](/api/html-core/officeimo-html-dom-htmlelement/#method-appendchild-htmlnode)
- Method [HtmlElement.Descendants](/api/html-core/officeimo-html-dom-htmlelement/#method-descendants)
- Property [HtmlElement.ChildNodes](/api/html-core/officeimo-html-dom-htmlelement/#property-childnodes)
- Property [HtmlElement.FirstChild](/api/html-core/officeimo-html-dom-htmlelement/#property-firstchild)
- Property [HtmlElement.NextSibling](/api/html-core/officeimo-html-dom-htmlelement/#property-nextsibling)
- Property [HtmlElement.Parent](/api/html-core/officeimo-html-dom-htmlelement/#property-parent)
- Property [HtmlElement.PreviousSibling](/api/html-core/officeimo-html-dom-htmlelement/#property-previoussibling)
- Method [HtmlNode.AppendChild](/api/html-core/officeimo-html-dom-htmlnode/#method-appendchild-officeimo-html-dom-htmlnode)
- Method [HtmlNode.Descendants](/api/html-core/officeimo-html-dom-htmlnode/#method-descendants)
- Property [HtmlNode.ChildNodes](/api/html-core/officeimo-html-dom-htmlnode/#property-childnodes)
- Property [HtmlNode.FirstChild](/api/html-core/officeimo-html-dom-htmlnode/#property-firstchild)
- Property [HtmlNode.NextSibling](/api/html-core/officeimo-html-dom-htmlnode/#property-nextsibling)
- Property [HtmlNode.Parent](/api/html-core/officeimo-html-dom-htmlnode/#property-parent)
- Property [HtmlNode.PreviousSibling](/api/html-core/officeimo-html-dom-htmlnode/#property-previoussibling)

### Accepted by parameters 9

- Method [HtmlDocument.AppendChild](/api/html-core/officeimo-html-dom-htmldocument/#method-appendchild-htmlnode) parameter `child`
- Method [HtmlDocument.ImportNode](/api/html-core/officeimo-html-dom-htmldocument/#method-importnode-officeimo-html-dom-htmlnode-boolean-threading-cancellationtoken) parameter `source`
- Method [HtmlDocument.SetSourceIndex](/api/html-core/officeimo-html-dom-htmldocument/#method-setsourceindex-officeimo-html-dom-htmlnode-nullable-system-int32) parameter `node`
- Method [HtmlDocumentFragment.AppendChild](/api/html-core/officeimo-html-dom-htmldocumentfragment/#method-appendchild-htmlnode) parameter `child`
- Method [HtmlDocumentType.AppendChild](/api/html-core/officeimo-html-dom-htmldocumenttype/#method-appendchild-htmlnode) parameter `child`
- Method [HtmlElement.AppendChild](/api/html-core/officeimo-html-dom-htmlelement/#method-appendchild-htmlnode) parameter `child`
- Method [HtmlNode.AppendChild](/api/html-core/officeimo-html-dom-htmlnode/#method-appendchild-officeimo-html-dom-htmlnode) parameter `child`
- Method [IHtmlDomServices.QuerySelectorAll](/api/html-core/officeimo-html-dom-ihtmldomservices/#method-queryselectorall-officeimo-html-dom-htmlnode-string) parameter `scope`
- Method [IHtmlDomServices.Serialize](/api/html-core/officeimo-html-dom-ihtmldomservices/#method-serialize-officeimo-html-dom-htmlnode-boolean) parameter `node`

Filter members 

Show inherited

## Methods

`public HtmlNode AppendChild(HtmlNode child)` [#](#method-appendchild-officeimo-html-dom-htmlnode)

[HtmlNode.cs:74](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L74)

Appends or moves a node in the same mutable document. Cycles and cross-document moves are rejected.

Parameters

**child OfficeIMO.Html.Dom.HtmlNode required**

Returns

`HtmlNode`

`public IEnumerable<HtmlNode> Descendants()` [#](#method-descendants)

Enumerates descendants in tree order without recursive traversal.

Returns

`IEnumerable<HtmlNode>`

`public HtmlElement? QuerySelector(string selector)` [#](#method-queryselector-string)

[HtmlNode.cs:122](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L122)

Finds the first descendant matching a CSS selector.

Parameters

**selector string required**

Returns

`HtmlElement?`

`public IReadOnlyList<HtmlElement> QuerySelectorAll(string selector)` [#](#method-queryselectorall-string)

[HtmlNode.cs:125](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L125)

Finds matching descendants using this document's selector provider.

Parameters

**selector string required**

Returns

`IReadOnlyList<HtmlElement>`

`public void Remove()` [#](#method-remove)

[HtmlNode.cs:103](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L103)

Detaches this node without affecting sibling nodes.

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Properties

`public HtmlDocument Document { get; }` [#](#property-document)

[HtmlNode.cs:22](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L22)

Document owning this node, including detached nodes.

`public int NodeId { get; }` [#](#property-nodeid)

[HtmlNode.cs:24](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L24)

Stable node identity within this document's edit lineage.

`public HtmlNodeKind Kind { get; }` [#](#property-kind)

[HtmlNode.cs:26](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L26)

Structural node category.

`public HtmlNode? Parent { get; private set; }` [#](#property-parent)

[HtmlNode.cs:28](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L28)

Parent node, or null for the document and detached nodes.

`public HtmlElement? ParentElement { get; }` [#](#property-parentelement)

[HtmlNode.cs:31](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L31)

Parent element when the immediate parent is an element.

`public IReadOnlyList<HtmlNode> ChildNodes { get; }` [#](#property-childnodes)

[HtmlNode.cs:33](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L33)

Ordered child nodes. The collection cannot be mutated directly.

`public IEnumerable<HtmlElement> Children { get; }` [#](#property-children)

[HtmlNode.cs:35](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L35)

Direct child elements in source/tree order.

`public HtmlNode? FirstChild { get; }` [#](#property-firstchild)

[HtmlNode.cs:37](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L37)

First child, if any.

`public HtmlNode? NextSibling { get; }` [#](#property-nextsibling)

[HtmlNode.cs:39](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L39)

Next sibling, if any.

`public HtmlNode? PreviousSibling { get; }` [#](#property-previoussibling)

[HtmlNode.cs:41](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L41)

Previous sibling, if any.

`public int? SourceIndex { get; internal set; }` [#](#property-sourceindex)

[HtmlNode.cs:43](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L43)

Original UTF-16 source offset, or null for an implied or authored node.

`public virtual string NodeName { get; }` [#](#property-nodename)

[HtmlNode.cs:45](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L45)

Node name for non-element nodes; elements expose their local name.

`public string TextContent { get; set; }` [#](#property-textcontent)

[HtmlNode.cs:49](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L49)

Text or comment data. Container nodes aggregate descendant text.

`public string OuterHtml { get; }` [#](#property-outerhtml)

[HtmlNode.cs:68](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L68)

HTML serialization of this node.

`public string InnerHtml { get; }` [#](#property-innerhtml)

[HtmlNode.cs:70](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Html.Core/HtmlNode.cs#L70)

HTML serialization of this node's children.

<!-- PowerForge markdown artifact sha256:8FD297551DE9142169B35D39BF8DFA71C2C1A09FCFCA131BB7FC37E5E833753F -->
