Markup Processing Modules
xml.dom
Defines the Python DOM interfaces, node type constants and exceptions. DOM exposes documents, elements, attributes and text as nodes. Choose an implementation such as minidom to construct or parse a document. Use bounded trusted XML; parsing hostile input requires a security review and resource limits.
Formal Syntax & Structure
python syntaxpython
import xml.domReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from xml.dom import Node, minidomwith minidom.parseString("<label>Tea</label>") as doc: node = doc.documentElement.firstChild print(node.nodeType == Node.TEXT_NODE, node.data)