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
2010-10-23 15:40:12
The xml.dom.ext module doesn't seem to be a part of the standard library. Where does this library come from?
echo-flow
2010-10-23 16:14:18
This is part of the PyXML package, not standard Python libraries.
ma3
2010-10-23 16:32:36
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
2010-10-23 18:17:11
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
2010-10-23 18:38:49
Hmm, I'm all out of ideas then, sorry...
Michael Goldshteyn
2010-10-23 18:43:09
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
2010-10-23 19:14:38