Range
Range
概述
Range 是 Aspose.Html FOSS 中用于 Python 的一个类。继承自:AbstractRange。
文档树的连续部分(WHATWG DOM §5)。
此类为在 Python 程序中使用 Range 对象提供了 23 个方法。可用的方法包括:__init__、clone_contents、clone_range、collapse、compare_boundary_points、compare_point、create_contextual_fragment、delete_contents、detach、extract_contents、insert_node、intersects_node,以及另外 11 个方法。所有公共成员在安装了 Aspose.Html FOSS for Python 包后,对任何 Python 应用程序均可访问。属性:collapsed、common_ancestor_container、end_container、end_offset、start_container、start_offset。
属性
| 名称 | 类型 | 访问 | 描述 |
|---|---|---|---|
common_ancestor_container | "Node" | 读取 | 包含两个边界点的最深节点。 |
start_container | "Node" | 读取 | 包含范围起始点的节点。 |
start_offset | int | 读取 | 在 start_container 中的偏移量。 |
end_container | "Node" | 读取 | 包含范围结束的节点。 |
end_offset | int | 读取 | 在 end_container 中的偏移量。 |
collapsed | bool | 读取 | 如果起始和结束边界点相同,则为真。 |
方法
| 签名 | 描述 |
|---|---|
__init__(owner_document: "Node") | 在 (owner_document, 0) 处创建一个折叠范围。 |
set_start(node: "Node", offset: int) | 设置范围的起始边界。 |
set_end(node: "Node", offset: int) | 设置范围的结束边界。 |
set_start_before(node: "Node") | 将起始位置设置为前一个位置 node 在其父级中。 |
set_start_after(node: "Node") | 将起始位置设置为紧随其后的位点 node 在其父级中。 |
set_end_before(node: "Node") | 将结束位置设置为紧接之前的位点 node 在其父级中。 |
set_end_after(node: "Node") | 将结束位置设为紧随其后的位点 node 在其父级中。 |
collapse(to_start: bool) | 将范围折叠到起始或结束边界点。 |
select_node(node: "Node") | Select node 以及其所有内容。 |
select_node_contents(node: "Node") | 选择其内容 node (而不是节点本身)。 |
extract_contents() → "DocumentFragment" | 删除并返回所选内容,作为一个DocumentFragment。 |
clone_contents() → "DocumentFragment" | 返回一个包含所选内容深拷贝的DocumentFragment。 |
delete_contents() | 从文档中删除所选内容。 |
insert_node(node: "Node") | Insert node 在范围的起始处。 |
surround_contents(new_parent: "Node") | 将范围的内容包裹在 new_parent. |
clone_range() → "Range" | 返回一个具有相同边界点的新 Range。 |
detach() | 从实时变异跟踪中注销此范围。 |
is_point_in_range(node: "Node", offset: int) → bool | 如果 (node, offset) 落在范围内(包括边界),则返回 True。 |
compare_point(node: "Node", offset: int) → int | 返回 -1、0 或 1,比较 (node, offset) 与范围的关系。 |
compare_boundary_points(how: int, source_range: "Range") → int | 使用边界模式 how 将此范围与 source_range 进行比较。 |
create_contextual_fragment(fragment: str) → "DocumentFragment" | 在此范围的起始边界元素上下文中解析 fragment。 |
intersects_node(node: "Node") → bool | 如果满足以下条件则返回 True。 node 部分或完全位于该范围内。 |
to_string() → str | 返回该范围的拼接文本内容。 |