Python DOM Offerings
Python has several different ways for working with the
DOM. The one you choose should best fit your needs. minidom is smaller and faster than a fully
compliant DOM, but suits the needs of most users. pulldom provides a way to build only the
portion of the DOM needed for a particular application, allowing the DOM
to be more easily used when working with large documents or tight memory
constraints. 4DOM is a full-fledged DOM Level 2 implementation. While
these are the dominant implementations of the DOM for Python, and the
only implementations described here, realize that there are additional
implementations available that may be more tailored to your
requirements.
Streamlining with Minidom
minidom , part of the xml.dom
package included with both the Python standard library and PyXML, is a
lightweight DOM implementation. Its goal is to provide a simple
implementation and smaller memory footprint than a full DOM
implementation. The methods for creating the DOM are simple as well.
minidom also supports functions for
working with string-length XML chunks and methods for extracting
them.
Overall, minidom may be best
for loading simple (not necessarily small) configuration files for
your applications, dealing with form submissions from web pages,
handling user authorization, and using it anywhere a “little” bit of
XML is needed. You can reduce memory and time overhead by using
minidom. These are two elements of significant importance in web application development. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access