Re: Using the indent method

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dj

    Re: Using the indent method

    Hello All,

    I am using elementtree to write an XML document and I am having a hard
    time adding the correct indentation.
    I have tried using the indent method, but I can not figure out how to
    use it. Any suggestions.
  • Mark Tolonen

    #2
    Re: Using the indent method


    "dj" <d.a.abernathy@ gmail.comwrote in message
    news:ffbc75e3-612b-4195-b9c1-11df9e66d286@f6 3g2000hsf.googl egroups.com...
    Hello All,
    >
    I am using elementtree to write an XML document and I am having a hard
    time adding the correct indentation.
    I have tried using the indent method, but I can not figure out how to
    use it. Any suggestions.
    Using the version of indent() found on

    >>from xml.etree import ElementTree as ET
    >>x='<a><b /><c /><d>stuff</d><e><f /></e></a>'
    >>e=ET.fromstri ng(x)
    >>ET.dump(e)
    <a><b /><c /><d>stuff</d><e><f /></e></a>
    >>indent(e)
    >>ET.dump(e)
    <a>
    <b />
    <c />
    <d>stuff</d>
    <e>
    <f />
    </e>
    </a>

    -Mark

    Comment

    Working...