Markup Processing Modules
xml.dom.pulldom
Consume XML events while selectively expanding DOM subtrees. parseString() produces an event stream; expandNode() consumes events needed to populate a selected node. This can avoid constructing an entire tree but is not a guarantee of bounded memory for arbitrary input. Use bounded trusted XML; parsing hostile input requires a security review and resource limits.
Formal Syntax & Structure
python syntaxpython
import xml.dom.pulldomReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from xml.dom import pulldomstream = pulldom.parseString("<r><item>Tea</item></r>")try: for event, node in stream: if event == pulldom.START_ELEMENT and node.tagName == "item": stream.expandNode(node) print(node.firstChild.data)finally: stream.clear()