minidom question from a newbie

Peter Hansen peter at engcorp.com
Wed Jan 29 10:34:13 EST 2003


henk.derudder at nowayyouneedthis.sciatl.com wrote:
> 
> I am using minidom from xml.dom. There is a nice method in there:
> root = minidom.parse(filename)
> which gives me a nice tree of all XML-elements which are in the file
> filename. Is there a possibility to go the other way around, i.e. to
> have  such a tree structure and save it into an XML-file. If yes, are
> there snippets/sample code out there.

# assuming a DOM object in variable "dom"
f = open('test.xml', 'w')
dom.writexml(f)
f.close()

-Peter




More information about the Python-list mailing list