Markup Processing Modules

xml

Package grouping standard-library XML processing interfaces. ElementTree builds element trees, DOM represents document nodes, and SAX reports parser events. The package namespace alone is not a parser; import the appropriate submodule. Use bounded trusted XML; parsing hostile input requires a security review and resource limits.

Formal Syntax & Structure

python syntaxpython
import xml

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
import xml.etree.ElementTree as ETroot = ET.fromstring('<items><item id="7"/></items>')print(root.tag, root.find("item").get("id"))
Python Reference