tags:

views:

47

answers:

1

I'd like to know how I can serialize an XML document in python specifically using the xml.dom library.

+1  A: 

You mean something like:

xml.dom.ext.PrettyPrint(doc, open(name, "w"))

where doc is the XML document and name is the name of the file?

Or, if you have xml.dom.minidom, how about the xml.dom.minidom.writexml function?

Michael Goldshteyn
The xml.dom.ext module doesn't seem to be a part of the standard library. Where does this library come from?
echo-flow
This is part of the PyXML package, not standard Python libraries.
ma3
It seems that PyXML is no longer maintained, according to a note on their download page on sourceforge: http://sourceforge.net/projects/pyxml/files/ Is there a way to do this that uses a library that is maintained?
echo-flow
Regarding minidom, it strangely does not support serialization of namespaces: http://untidy.net/blog/2006/03/03/writing-xml-with-namespaces-from-minidom/ This is rather important for my application.
echo-flow
Hmm, I'm all out of ideas then, sorry...
Michael Goldshteyn
Thanks for trying, I appreciate it. I've spun off a new question to address what I feel may be the more general problem: http://stackoverflow.com/questions/4005641/is-python-bad-at-xml
echo-flow