Comparing two minidom objects

Uche Ogbuji uche at
Fri Nov 12 23:52:41 CET 2004

skip at (Skip Montanaro) wrote in message news:<727daa7e.0411081033.276d5eba at>...
> I'd like to compare two xml.dom.minidom objects, but the naive attempt fails:
> >>> import xml.dom.minidom
> >>> d1 = xml.dom.minidom.parse("ES.xml")
> >>> d2 = xml.dom.minidom.parse("ES.xml")
> >>> d1 == d2
> False
> My goal is to decide whether or not I need to prompt the user to save config
> information at the end of a program run by generating a minidom object then
> comparing it with the last saved version.

Last heading.

Short answer: use c14n (xml.dom.ext.c14n in PyXML), or an XML smart
tree compare function, such as the one that comes with 4Suite.

Uche Ogbuji                                    Fourthought, Inc.
A hands-on introduction to ISO Schematron -
Schematron abstract patterns -
Wrestling HTML (using Python) -
XML's growing pains -
XMLOpen and more XML Hacks -
A survey of XML standards -

More information about the Python-list mailing list