I'd like to know how I can serialize an XML document in python specifically using the xml.dom library.
1 Answer
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?
5 Comments
jbeard4
The xml.dom.ext module doesn't seem to be a part of the standard library. Where does this library come from?
snapshoe
This is part of the PyXML package, not standard Python libraries.
jbeard4
It seems that PyXML is no longer maintained, according to a note on their download page on sourceforge: sourceforge.net/projects/pyxml/files Is there a way to do this that uses a library that is maintained?
jbeard4
Regarding minidom, it strangely does not support serialization of namespaces: untidy.net/blog/2006/03/03/… This is rather important for my application.
jbeard4
Thanks for trying, I appreciate it. I've spun off a new question to address what I feel may be the more general problem: stackoverflow.com/questions/4005641/is-python-bad-at-xml