June 2019
Beginner to intermediate
770 pages
19h 24m
English
We can use the xml.etree.ElementTree module to build Element structures that can be emitted as XML. It's challenging to use xml.dom and xml.minidom for this. The DOM API requires a top-level document that then builds individual elements. The presence of this necessary context object creates clutter when trying to serialize a simple class with several attributes. We have to create the document first and then serialize all the elements of the document, providing the document context as an argument.
Generally, we'd like each class in our design to build a top-level element and return that. Most top-level elements will have a sequence of subelements. We can assign text as well as attributes to each element ...
Read now
Unlock full access