Google Groups Home
Help | Sign in
Using the indent method
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
dj  
View profile
 More options May 14, 3:25 pm
Newsgroups: comp.lang.python
From: dj <d.a.aberna...@gmail.com>
Date: Wed, 14 May 2008 12:25:45 -0700 (PDT)
Local: Wed, May 14 2008 3:25 pm
Subject: 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.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Tolonen  
View profile
 More options May 14, 9:54 pm
Newsgroups: comp.lang.python
From: "Mark Tolonen" <M8R-yft...@mailinator.com>
Date: Wed, 14 May 2008 18:54:31 -0700
Local: Wed, May 14 2008 9:54 pm
Subject: Re: Using the indent method

"dj" <d.a.aberna...@gmail.com> wrote in message

news:ffbc75e3-612b-4195-b9c1-11df9e66d286@f63g2000hsf.googlegroups.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
http://effbot.org/zone/element-lib.htm:

>>> from xml.etree import ElementTree as ET
>>> x='<a><b /><c /><d>stuff</d><e><f /></e></a>'
>>> e=ET.fromstring(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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google