xml.dom.minidom memory usage

Jonathan Curran jonc at icicled.net
Thu Feb 1 15:12:36 EST 2007


Dan,
	The DOM (Document Object Model) is such that it loads all the elements of the 
XML document into memory before you can do anything with it. With your file 
containing millions of child nodes this will eat up as much memory as you 
have. A solution to this is to use the SAX method of parsing XML documents 
and working on it. SAX is such that it only reads the XML doc. a node (or a 
few nodes) at a time.

Unfortunately, the use of DOM or SAX completely depends on what kind of 
processing you need to be done on the XML document. If it is editing a record 
at a time (from what I've gathered from your code) it would be wise to use 
SAX. I highly suggest looking into this method of processing.

- Jonathan Curran



More information about the Python-list mailing list