Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: ElementTree write creates large one line XML file ....

Reply
Thread Tools

Re: ElementTree write creates large one line XML file ....

 
 
Robert Kern
Guest
Posts: n/a
 
      05-28-2010
On 5/27/10 7:52 PM, robert somerville wrote:
> Hi I am using Ubuntu 9.10 and Python 2.6.4 ..
>
> when I create an ElementTree object and the write it out using:
>
> xml.etree.ElementTree.write() , I get one single long single line
> files, instead of something that looks reasonable , what gives ??? (and
> is it important ??)


ElementTree writes exactly what you tell it to. In XML, whitespace is
significant. If you want newlines and/or indentation to make it pretty-looking,
then you need to add those to your elements.

Fredrik provides an example function for doing this:

http://effbot.org/zone/element-lib.htm#prettyprint

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
email.encoders.encode_base64 creates one line only spam@uce.gov Python 1 02-10-2011 03:51 PM
no line breaks in xml file with elementTree hackingKK Python 4 10-31-2010 10:07 PM
Re: How to get xml.etree.ElementTree not bomb on invalid charactersin XML file ? Stefan Behnel Python 0 05-04-2010 07:23 AM
ElementTree.XML(string XML) and ElementTree.fromstring(string XML)not working Kee Nethery Python 12 06-27-2009 06:06 AM
Read a file line by line and write each line to a file based on the5th byte scad C++ 23 05-17-2009 06:11 PM



Advertisments