TreeWalker
Overview
TreeWalker is a class in Aspose.Html FOSS for Python.
Cursor-style DOM traversal bounded to a root subtree.
This class provides 8 methods for working with TreeWalker objects in Python programs.
Available methods include: __init__, first_child, last_child, next_node, next_sibling, parent_node, previous_node, previous_sibling.
All public members are accessible to any Python application after installing the Aspose.Html FOSS for Python package.
Properties: current_node, filter, root, what_to_show.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
root | "Node" | Read | The root node of this walker’s subtree. |
what_to_show | int | Read | The what_to_show bitmask passed at construction. |
filter | "Callable[[Node], int] | None" | Read | The user-supplied filter callable, or None. |
current_node | "Node" | Read/Write | The walker’s current position node. |
Methods
| Signature | Description |
|---|---|
__init__(root: "Node", what_to_show: int, node_filter: "Callable[[Node], int] | None") | Initialise a TreeWalker. |
parent_node() → "Node | None" | Move to and return the nearest accepted ancestor within the root boundary. |
first_child() → "Node | None" | Move to and return the first accepted child of current_node. |
last_child() → "Node | None" | Move to and return the last accepted child of current_node. |
previous_sibling() → "Node | None" | Move to and return the previous accepted sibling. |
next_sibling() → "Node | None" | Move to and return the next accepted sibling. |
next_node() → "Node | None" | Move to and return the next node in document order. |
previous_node() → "Node | None" | Move to and return the previous node in document order. |