custom xml pretty print

Diez B. Roggisch deets at nospam.web.de
Sun Nov 20 06:53:23 EST 2005


akbar wrote:
> Hi,
> 
> I have Document. If I print it like this:
> 
> print doc.toprettyxml("  ")
> 
> I will get this:
> <a>
>   <b>
>     <c>
>       blablablabla
>     </c>
>   </b>
> </a>
> 
> What do I have to do if I want to print it like this:
> <a>
>   <b>
>     <c>blablablabla</c>
>   </b>
> </a>

Use a SAX-Handler, parse it yourself and pretty-print your own. You 
_could_ use DOM, but I don't think its needed here.

Diez



More information about the Python-list mailing list