Text
Overview
Text is a class in Aspose.Html FOSS for Python.
Inherits from: CharacterData.
A text node.
This class provides 30 methods for working with Text objects in Python programs.
Available methods include: __init__, add_event_listener, append_child, append_data, clone_node, compare_document_position, contains, delete_data, dispatch_event, get_feature, get_root_node, get_user_data, and 18 additional methods.
All public members are accessible to any Python application after installing the Aspose.Html FOSS for Python package.
Properties: child_nodes, data, first_child, is_connected, last_child, length, and 10 more.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
node_name | str | Read | '#text' |
whole_text | str | Read | Concatenated data of all contiguous Text nodes around this node. |
node_value | str | Read/Write | The character data content (same as data). |
text_content | str | None | Read/Write | The character data content (same as data). |
data | str | Read/Write | The character data content. |
length | int | Read | The number of code units in data. |
node_type | int | Read | Integer node type constant from NodeType. |
parent_node | Node | None | Read | The parent node, or None if this node has no parent. |
parent_element | Element | None | Read | The parent node if it is an Element; None otherwise. |
is_connected | bool | Read | Whether this node is part of a document’s node tree (WHATWG DOM §4.4). |
owner_document | Document | None | Read | The Document this node belongs to, or None for Document itself. |
child_nodes | NodeList | Read | A live NodeList of all child nodes. |
first_child | Node | None | Read | The first child node, or None. |
last_child | Node | None | Read | The last child node, or None. |
previous_sibling | Node | None | Read | The preceding sibling node, or None. |
next_sibling | Node | None | Read | The following sibling node, or None. |
Methods
| Signature | Description |
|---|---|
__init__(data: str, owner_document: Document | None) | Calls init(data, owner_document) on this Text instance. |
split_text(offset: int) → "Text" | Split this Text node at offset, returning the new trailing node. |
substring_data(offset: int, count: int) → str | Return a substring of data starting at offset for count chars. |
append_data(data: str) | Append data to the existing character data. |
insert_data(offset: int, data: str) | Insert data at offset. |
delete_data(offset: int, count: int) | Delete count characters starting at offset. |
replace_data(offset: int, count: int, data: str) | Replace count characters from offset with data. |
remove() | Remove this node from its parent node. |
get_root_node(composed: bool) → "Node" | Return the root of the node’s tree. |
has_child_nodes() → bool | Return whether this node has at least one direct child node. |
lookup_namespace_uri(prefix: str | None) → str | None | Return the effective namespace URI for prefix in this node context. |
lookup_prefix(namespace_uri: str | None) → str | None | Return the effective prefix for namespace_uri in this node context. |
is_default_namespace(namespace_uri: str | None) → bool | Return whether namespace_uri equals this node context default namespace. |
is_supported(feature: str, version: str | None) → bool | Return legacy feature-probe compatibility status. |
get_feature(feature: str, version: str | None) → object | None | Return the legacy feature object for a probe, or None. |
set_user_data(key: str, data: object | None, handler: object | None) → object | None | Store or clear node-local user data and return the previous value. |
get_user_data(key: str) → object | None | Return node-local user data for key or None when absent. |
append_child(node: Node) → Node | Append node as the last child of this node. |
insert_before(node: Node, reference: Node | None) → Node | Insert node before reference in the child list. |
remove_child(node: Node) → Node | Remove node from the child list and return it. |
replace_child(new_child: Node, old_child: Node) → Node | Replace old_child with new_child. |
clone_node(deep: bool) → Node | Return a copy of this node. |
normalize() | Put this node and its entire subtree into normalized form. |
contains(other: Node | None) → bool | Return True if other is an inclusive descendant of this node. |
compare_document_position(other: "Node") → int | Return a bitmask describing the position of other relative to this node. |
is_equal_node(other: Node | None) → bool | Return True if other has the same structure as this node. |
is_same_node(other_node: Node | None) → bool | Return True when other_node is this node instance. |
add_event_listener(type: str, listener: Callable, capture: bool, once: bool) | Register listener for events of type. |
remove_event_listener(type: str, listener: Callable, capture: bool) | Deregister a previously-registered listener. |
dispatch_event(event: "Event") → bool | Dispatch event through the ancestor tree. |