custom xml pretty print

Discussion in 'Python' started by akbar, Nov 20, 2005.

  1. akbar

    akbar Guest

    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>

    Thank you.
    akbar, Nov 20, 2005
    #1
    1. Advertising

  2. 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
    Diez B. Roggisch, Nov 20, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Montgomery
    Replies:
    0
    Views:
    602
    Andrew Montgomery
    Sep 17, 2003
  2. edw
    Replies:
    2
    Views:
    9,428
  3. Alan G Isaac

    pretty print 2D arrays

    Alan G Isaac, Aug 12, 2004, in forum: Python
    Replies:
    1
    Views:
    535
    Colin J. Williams
    Aug 13, 2004
  4. Pk Z.
    Replies:
    3
    Views:
    203
    Mike Dalessio
    Jan 13, 2011
  5. Phlip
    Replies:
    2
    Views:
    1,010
    japisoft
    May 7, 2012
Loading...

Share This Page