ElementTree and proper identation?

John Salerno johnjsal at NOSPAMgmail.com
Wed Sep 27 14:06:15 EDT 2006


John Salerno wrote:
> I've been doing a little studying of ElementTree and it doesn't seem 
> very satisfactory for writing XML files that are properly 
> formatted/indented. I saw on the website that there is an 
> indent/prettyprint function, but this isn't listed in the Python docs 
> and I didn't see it after doing a dir(), so I guess it isn't a part of 
> the Python version.
> 
> Did I miss something somewhere else, or can you just not use ElementTree 
> to write formatted XML files as they'd look if done by hand?
> 
> Thanks.

Well, further research reveals that this function isn't available yet in 
any version. But I guess my question remains, is there still a way to do 
this, given the way Element instances are constructed? I would assume 
you can't just use ElementTree to write them to a file, but perhaps 
there is a different way to write to a file that still uses the Element 
objects?



More information about the Python-list mailing list