The techniques described in the section above, Section 12, “Creating a document from scratch: factory methods”, are somewhat clumsy. This clumsiness is due to the DOM's language-independent charter.
Here, in “literate programming” style, is a
small Python module named
xml4create.py that gives you a more Pythonic tool for XML file
creation. For more on
literate programming, see A source extractor for lightweight literate
For links to the source files developed here, see Section 1.1, “How to get this publication”.
Here are the classes exported by the
If your document is to have a
...> declaration attached, you must
with that information before creating your
Document object, because the document type
is an argument to the
The constructor has this calling sequence:
The arguments are:
The qualified name of the root element.
The public identifier, if any, as a string. To get
document type identifier, pass
rootGI SYSTEM ...>
None as this argument.
The system identifier as a string. Required.