DocumentFragment
DocumentFragment
ภาพรวม
DocumentFragment คือคลาสใน Aspose.Html FOSS สำหรับ Python. สืบทอดจาก: Node.
คอนเทนเนอร์น้ำหนักเบาสำหรับโครงย่อย.
คลาสนี้ให้ 28 เมธอดสำหรับทำงานกับอ็อบเจกต์ DocumentFragment ในโปรแกรม Python. เมธอดที่มีรวมถึง: __init__, add_event_listener, append, append_child, clone_node, compare_document_position, contains, dispatch_event, get_feature, get_root_node, get_user_data, has_child_nodes, และเมธอดเพิ่มเติมอีก 16 รายการ. สมาชิกสาธารณะทั้งหมดสามารถเข้าถึงได้โดยแอปพลิเคชัน Python ใด ๆ หลังจากติดตั้งแพ็กเกจ Aspose.Html FOSS สำหรับ Python. คุณสมบัติ: child_nodes, first_child, is_connected, last_child, next_sibling, node_name, และเพิ่มเติมอีก 7 รายการ.
คุณสมบัติ
| ชื่อ | ประเภท | การเข้าถึง | คำอธิบาย |
|---|---|---|---|
node_name | str | อ่าน | '#document-fragment' |
text_content | `str | None` | อ่าน/เขียน |
node_type | int | อ่าน | ค่าคงที่ประเภทโหนดจำนวนเต็มจาก NodeType. |
node_value | `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(owner_document: Document | None)` |
prepend() | Insert nodes ก่อนลูกแรกของ fragment นี้. |
append() | Append nodes เป็นลูกสุดท้ายของ fragment นี้. |
replace_children() | ลบ children ทั้งหมดของ fragment นี้ แล้ว append nodes. |
query_selector(selector: str) → `“Element | None”` |
query_selector_all(selector: str) → "NodeList" | คืนค่า NodeList แบบคงที่ของทุกองค์ประกอบในส่วน fragment นี้ที่ตรงกับ selector. |
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 ผ่านต้นไม้บรรพบุรุษ. |