Skip to main content

Module tree

Module tree 

Source
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 iter but 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.