Attr
Attr
概述
Attr 是 Aspose.Html FOSS 中用于 Python 的类。继承自:Node。
附加到 Element 的属性。
此类提供了 23 个用于在 Python 程序中操作 Attr 对象的方法。可用的方法包括:__init__、add_event_listener、append_child、clone_node、compare_document_position、contains、dispatch_event、get_feature、get_root_node、get_user_data、has_child_nodes、insert_before,以及另外 11 个方法。所有公共成员在安装 Aspose.Html FOSS for Python 包后,任何 Python 应用程序均可访问。属性有:child_nodes、first_child、is_connected、last_child、local_name、name,以及另外 14 项。
属性
| 名称 | 类型 | 访问 | 描述 |
|---|---|---|---|
node_name | str | 读取 | 属性名称。 |
node_value | str | 读写 | 属性值字符串。 |
name | str | 读取 | 属性名称。 |
value | str | 读写 | 属性值。 |
owner_element | `Element | None` | 读取 |
namespace_uri | `str | None` | 读取 |
prefix | `str | None` | 读取 |
specified | bool | 读取 | 始终 True — DOM3 传统属性。 |
local_name | str | 读取 | 属性名称的本地部分。 |
node_type | int | 读取 | 来自 NodeType 的整数节点类型常量。 |
text_content | `str | None` | 读写 |
parent_node | `Node | None` | 读取 |
parent_element | `Element | None` | 读取 |
is_connected | bool | 读取 | 此节点是否是文档节点树的一部分(WHATWG DOM §4.4)。 |
owner_document | `Document | None` | 读取 |
child_nodes | NodeList | 读取 | 所有子节点的实时 NodeList。 |
first_child | `Node | None` | 读取 |
last_child | `Node | None` | 读取 |
previous_sibling | `Node | None` | 读取 |
next_sibling | `Node | None` | 读取 |
方法
| 签名 | 描述 |
|---|---|
| `init(name: str, value: str, owner_element: Element | None, owner_document: Document |
get_root_node(composed: bool) → "Node" | 返回节点树的根。 |
has_child_nodes() → bool | 返回此节点是否至少拥有一个直接子节点。 |
| `lookup_namespace_uri(prefix: str | None)→str |
| `lookup_prefix(namespace_uri: str | None)→str |
| `is_default_namespace(namespace_uri: str | None)→bool` |
| `is_supported(feature: str, version: str | None)→bool` |
| `get_feature(feature: str, version: str | None)→object |
| `set_user_data(key: str, data: object | None, handler: object |
get_user_data(key: str) → `object | None` |
append_child(node: Node) → Node | Append 节点 作为此节点的最后一个子节点。 |
| `insert_before(node: Node, reference: Node | None)→Node` |
remove_child(node: Node) → Node | Remove 节点 从子列表中获取并返回它。 |
replace_child(new_child: Node, old_child: Node) → Node | Replace old_child 使用 new_child. |
clone_node(deep: bool) → Node | 返回此节点的副本。 |
normalize() | 将此节点及其整个子树转换为标准化形式。 |
| `contains(other: Node | None)→bool` |
compare_document_position(other: "Node") → int | 返回一个位掩码,描述 其他 相对于此节点。 |
| `is_equal_node(other: Node | None)→bool` |
| `is_same_node(other_node: Node | None)→bool` |
add_event_listener(type: str, listener: Callable, capture: bool, once: bool) | Register 监听器 用于事件的 类型. |
remove_event_listener(type: str, listener: Callable, capture: bool) | 注销先前已注册的监听器。 |
dispatch_event(event: "Event") → bool | Dispatch 事件 通过祖先树。 |