Expand description
Tree manipulation with lxml-style text/tail model.
This module provides functions for working with the text/tail model used in lxml-style HTML processing.
§Text vs Tail
In this model, elements have:
- Text: Text content BEFORE the first child element
- Tail: Text content AFTER the element’s closing tag
<div>
TEXT HERE <!-- div's "text" -->
<span>inner</span>
TAIL HERE <!-- span's "tail" -->
</div>Structs§
- Document
- Document represents an HTML document to be manipulated.
Functions§
- append
- Append child element.
- element
- Create a new element as a Document.
- extend
- Append multiple children.
- is_
void_ element - Check if tag is a void element (self-closing).
- iter
- Iterate elements matching tags.
- iter_
descendants - Like
iterbut excludes the element itself. - iter_
text - Get all text content with separator at level changes.
- remove
- Remove element from tree.
- set_
tail - Set tail text after element.
- set_
text - Set text before first child element.
- strip
- Strip element but keep children.
- strip_
elements - Remove all elements with given tags.
- strip_
tags - Strip tags from selection, keeping their content.
- sub_
element - Create child element and append to parent.
- tail
- Get text after element’s closing tag (tail).
- tail_
nodes - Get all tail text nodes for an element.
- text
- Get text before first child element.