Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

HtmlNode

OfficeIMO.Html.Dom

Namespace
OfficeIMO.Html.Dom
Assembly
OfficeIMO.Html.Core
Source revision
ba882f6b0d07 with working tree changes

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

Inheritance

  • object
  • HtmlNode

Derived Types

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.

Accepted by parameters 9

Methods

public HtmlNode AppendChild(HtmlNode child) #

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() #

Enumerates descendants in tree order without recursive traversal.

Returns

IEnumerable<HtmlNode>
public HtmlElement? QuerySelector(string selector) #

Finds the first descendant matching a CSS selector.

Parameters

selector string required

Returns

HtmlElement?
public IReadOnlyList<HtmlElement> QuerySelectorAll(string selector) #

Finds matching descendants using this document's selector provider.

Parameters

selector string required

Returns

IReadOnlyList<HtmlElement>
public void Remove() #

Detaches this node without affecting sibling nodes.

Properties

public HtmlDocument Document { get; } #

Document owning this node, including detached nodes.

public int NodeId { get; } #

Stable node identity within this document's edit lineage.

public HtmlNodeKind Kind { get; } #

Structural node category.

public HtmlNode? Parent { get; private set; } #

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

public HtmlElement? ParentElement { get; } #

Parent element when the immediate parent is an element.

public IReadOnlyList<HtmlNode> ChildNodes { get; } #

Ordered child nodes. The collection cannot be mutated directly.

public IEnumerable<HtmlElement> Children { get; } #

Direct child elements in source/tree order.

public HtmlNode? FirstChild { get; } #

First child, if any.

public HtmlNode? NextSibling { get; } #

Next sibling, if any.

public HtmlNode? PreviousSibling { get; } #

Previous sibling, if any.

public int? SourceIndex { get; internal set; } #

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

public virtual string NodeName { get; } #

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

public string TextContent { get; set; } #

Text or comment data. Container nodes aggregate descendant text.

public string OuterHtml { get; } #

HTML serialization of this node.

public string InnerHtml { get; } #

HTML serialization of this node's children.