pretty print xml document

Frederic LAURENT frederic.laurent at sxb.bsf.alcatel.fr
Tue Feb 8 05:12:41 EST 2000


I want to pretty print an xml document that I've created :


>>> from xml.dom.builder import Builder
>>> c=Builder()
>>> c.startElement("foo")
>>> c.text("bar")
>>> c.startElement("another")
>>> c.text("text")
>>> c.endElement("another")
>>> c.endElement("foo")
>>> c.document.toxml()
'<?xml version="1.0"?>\012<foo>bar<another>text</another></foo>'


I would like to have something like that :
<?xml version="1.0"?>
<foo>bar
  <another>text</another>
</foo>


Is there something done (an existing method/class)
to pretty print the xml document ?

thanks




More information about the Python-list mailing list