How to serialize an xml document in Python
Alex Martelli
aleax at aleax.it
Wed Mar 19 16:28:56 EST 2003
Antun Karlovac wrote:
> This sounds like a REALLY easy question, but for the life of me I
> can't seem to find a solution. I've created an XML document as
> follows:-
>
> impl = xml.dom.minidom.getDOMImplementation()
> doc = impl.createDocument( None, "element", None )
>
>
> And then I added plenty of nodes to it.
>
> So far I've been printing it out to the console:
>
> xml.dom.ext.PrettyPrint( doc )
>
> But now I want to assign the serialized string of the XML to a
> variable.
Perhaps
thevariable = doc.toprettyxml()
...?
Alex
More information about the Python-list
mailing list