TreeWalker Class

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

public sealed class TreeWalker

Properties

NameDescription
CurrentNodeGets or sets the node the walker is currently positioned at.
FilterGets the filter used to accept, reject or skip nodes, or null when there is none.
RootGets the root node of the traversal.
WhatToShowGets the bit mask of the node types the walker presents.

CurrentNode

TreeWalker.cs

Gets or sets the node the walker is currently positioned at.

public Node CurrentNode { get; set; }

Gets the filter used to accept, reject or skip nodes, or null when there is none.

public INodeFilter? Filter { get; }

Gets the root node of the traversal.

public Node Root { get; }

WhatToShow

TreeWalker.cs

Gets the bit mask of the node types the walker presents.

public uint WhatToShow { get; }

Methods

NameDescription
FirstChild()Moves to the first visible child of the current node and returns it, or null when there is none.
LastChild()Moves to the last visible child of the current node and returns it, or null when there is none.
NextNode()https://dom.spec.whatwg.org/#dom-treewalker-nextnode
NextSibling()Moves to the next visible sibling of the current node and returns it, or null when there is none.
ParentNode()https://dom.spec.whatwg.org/#dom-treewalker-parentnode
PreviousNode()https://dom.spec.whatwg.org/#dom-treewalker-previousnode
PreviousSibling()Moves to the previous visible sibling of the current node and returns it, or null when there is none.

FirstChild()

TreeWalker.cs

Moves to the first visible child of the current node and returns it, or null when there is none.

public Node? FirstChild()

LastChild()

TreeWalker.cs

Moves to the last visible child of the current node and returns it, or null when there is none.

public Node? LastChild()

NextNode()

TreeWalker.cs

https://dom.spec.whatwg.org/#dom-treewalker-nextnode

public Node? NextNode()

NextSibling()

TreeWalker.cs

Moves to the next visible sibling of the current node and returns it, or null when there is none.

public Node? NextSibling()

ParentNode()

TreeWalker.cs

https://dom.spec.whatwg.org/#dom-treewalker-parentnode

public Node? ParentNode()

PreviousNode()

TreeWalker.cs

https://dom.spec.whatwg.org/#dom-treewalker-previousnode

public Node? PreviousNode()

PreviousSibling()

TreeWalker.cs

Moves to the previous visible sibling of the current node and returns it, or null when there is none.

public Node? PreviousSibling()