[XML-SIG] Printing "quite" pretty DOMs?

Uche Ogbuji uche.ogbuji@fourthought.com
Tue, 09 Jul 2002 00:51:00 -0600


> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On July 4, 2002 08:04 am, Dinu Gherman wrote:
> > Now this is actually too pretty in my case! What I'd really
> > need is something between the cases above, namely:
> >
> >     <DESC>
> >         <PARA>foo</PARA>
> >         <PARA>bar</PARA>
> >     </DESC>
> >
> > i.e. with no extra whitespace added for text inside an ele-
> > ment. Has anybody already some snippet to do this or isn't
> > it that trivial, maybe?
> 
> xml.dom.ext.PrettyPrint(doc, file_object, encoding)
> 
> This gives you exactly what you're looking for. It's what I prefer as well.

FYI, if you have 4Suite from CVS installed, Ft.Xml.Domlette.PrettyPrint does 
the same thing, but with several important optimizations and character 
encoding bug fixes.  Most of these take advantage of the fact that 4Suite has 
ditched Python 1.5.2 support.

I have placed an item based on your exchange in my doc project:

http://uche.ogbuji.net/tech/akara/pyxml/dom-printing/


-- 
Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
Track chair, XML/Web Services One Boston: http://www.xmlconference.com/
The many heads of XML modeling - http://adtmag.com/article.asp?id=6393
Will XML live up to its promise? - http://www-106.ibm.com/developerworks/xml/li
brary/x-think11.html