XML beautifier?

Andreas Jung ajung at sz-sb.de
Thu Sep 9 14:09:48 EDT 1999


On Fri, Sep 03, 1999 at 02:57:09PM +0200, Magnus L. Hetland wrote:
> earlybird at mop.no (Alexander Staubo) writes:
> 
> > In article <19990902191223.A29226 at sz-sb.de>, ajung at sz-sb.de says...
> > > On Thu, Sep 02, 1999 at 05:29:40PM +0200, Alexander Staubo wrote:
> > > > I'm having a gas with the XML package and its DOM classes, but its toxml
> > > > () mechanism outputs mainly flat XML -- no visual structure in the form 
> > > > of line shifts or indentation. Is there a Python module that such 
> > > > beautification reasonably hassle-free?
> > > 
> > > Here is just a very stupid program which does the job. 
> > 
> > You're right. That was moronic. :)
> > 
> > >It works
> > > with regular expressions. You can although use the sgmllib
> > > to parse the file, find the tags with the unknown_starttag() and
> > > unknown_endtag() functions and indent the output corresponding.
> > 
> > Thanks for the pointer, I'll check it out. Any examples of this though? 
> > This is one module I have to say I have never touched.
> 
> Why not just use xmllib? (I mean - why sgmllib?)

Well....I prefer more general solutions. Because
XML is a subset of SGML sgmllib will do the job too :-)
However the main reason for using sgmllib is that I am 
working with real SGML documents in real life and I not sure
whether xmllib would do the job or not.  Another reason:
my own SGML parser (based low-level on sgmllop.c) is faster
than the XML parsers of the xmllib package - it's small,
fast and robust :-)

Cheers,
Andreas





More information about the Python-list mailing list