Node
Node
ภาพรวม
Node เป็นคลาสใน Aspose.Html FOSS สำหรับ Python. สืบทอดจาก: EventTarget, ABC.
คลาสฐานเชิงนามธรรมสำหรับโหนด WHATWG DOM ทั้งหมด.
คลาสนี้ให้ 23 เมธอดสำหรับทำงานกับอ็อบเจ็กต์ Node ในโปรแกรม Python. เมธอดที่มีให้รวมถึง: __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 รายการ. สมาชิกสาธารณะทั้งหมดสามารถเข้าถึงได้จากแอปพลิเคชัน Python ใด ๆ หลังจากติดตั้งแพ็กเกจ Aspose.Html FOSS สำหรับ Python. คุณสมบัติ: child_nodes, first_child, is_connected, last_child, next_sibling, node_name และอีก 7 รายการ.
คุณสมบัติ
| ชื่อ | ประเภท | การเข้าถึง | คำอธิบาย |
|---|---|---|---|
node_type | int | อ่าน | ค่าคงที่ชนิดโหนดจำนวนเต็มจาก NodeType. |
node_name | str | อ่าน | ชื่อของโหนดนี้ (ชื่อแท็ก, '#text', เป็นต้น). |
node_value | `str | None` | อ่าน/เขียน |
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(node_type: int, owner_document: Document | None)` |
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 node เป็นลูกสุดท้ายของโหนดนี้. |
| `insert_before(node: Node, reference: Node | None)→Node` |
remove_child(node: Node) → Node | Remove node จากรายการลูกและส่งกลับ. |
replace_child(new_child: Node, old_child: Node) → Node | Replace old_child with new_child. |
clone_node(deep: bool) → Node | คืนสำเนาของโหนดนี้. |
normalize() | แปลงโหนดนี้และต้นไม้ย่อยทั้งหมดให้เป็นรูปแบบมาตรฐาน. |
| `contains(other: Node | None)→bool` |
compare_document_position(other: "Node") → int | คืนค่า bitmask ที่อธิบายตำแหน่งของ other เทียบกับโหนดนี้. |
| `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 listener สำหรับเหตุการณ์ของ type. |
remove_event_listener(type: str, listener: Callable, capture: bool) | ยกเลิกการลงทะเบียนผู้ฟังที่เคยลงทะเบียนไว้. |
dispatch_event(event: "Event") → bool | Dispatch event ผ่านต้นไม้บรรพบุรุษ. |