Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > no line breaks in xml file with elementTree

Reply
Thread Tools

no line breaks in xml file with elementTree

 
 
hackingKK
Guest
Posts: n/a
 
      10-31-2010
Hello all.
I want to know if there is a way to have the ElementTree module write to
an xml file with line breaks?
I find that when I use the write function from the module on a tree
object, the resulting file has no line breaks. I don't want to use
prittyprint because it is adding extra tabs to the file and they are
either counted as extra nodes or in case of element.text with
elementtree, they are rendered as a part of the text, both being
impractical results.
So is there a middle approach where we can have some thing similar to
prityprint but without the extra tabs and yet having a properly line
breaked xml file?
Further more, I just was curious why elementtree is not having the
namespace facility?
xml.dom.minidom has a way to generate tags with namespaces.
Any thing similar in elementTree?

happy hacking.
Krishnakant.



 
Reply With Quote
 
 
 
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      10-31-2010
In message <(E-Mail Removed)>, hackingKK
wrote:

> I want to know if there is a way to have the ElementTree module write to
> an xml file with line breaks?


Why does it matter? The XML files you generate are not for humans to look
at, are they?

> Further more, I just was curious why elementtree is not having the
> namespace facility?


ElementTree handles namespaces just fine.
 
Reply With Quote
 
 
 
 
hackingKK
Guest
Posts: n/a
 
      10-31-2010
On Sunday 31 October 2010 01:58 PM, Lawrence D'Oliveiro wrote:
> In message<(E-Mail Removed)>, hackingKK
> wrote:
>
>
>> I want to know if there is a way to have the ElementTree module write to
>> an xml file with line breaks?
>>

> Why does it matter? The XML files you generate are not for humans to look
> at, are they?
>


So is there a function to generate tags with namespace?

happy hacking.
Krishnakant.

 
Reply With Quote
 
Stefan Behnel
Guest
Posts: n/a
 
      10-31-2010
hackingKK, 31.10.2010 10:04:
> On Sunday 31 October 2010 01:58 PM, Lawrence D'Oliveiro wrote:
>> hackingKK wrote:
>>> Further more, I just was curious why elementtree is not having the
>>> namespace facility?

>>
>> ElementTree handles namespaces just fine.

>
> So is there a function to generate tags with namespace?


Yes, it's called "Element", as in

el = ET.Element('{http://the.name/space}tag')

Reading the docs helps a lot here.

Stefan

 
Reply With Quote
 
Diez B. Roggisch
Guest
Posts: n/a
 
      10-31-2010
hackingKK <(E-Mail Removed)> writes:

> On Sunday 31 October 2010 01:58 PM, Lawrence D'Oliveiro wrote:
>> In message<(E-Mail Removed)>, hackingKK
>> wrote:
>>
>>
>>> I want to know if there is a way to have the ElementTree module write to
>>> an xml file with line breaks?
>>>

>> Why does it matter? The XML files you generate are not for humans to look
>> at, are they?
>>

>
> So is there a function to generate tags with namespace?


http://lmgtfy.com/?q=element+tree+namespac

--

Diez
 
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
Re: ElementTree write creates large one line XML file .... Robert Kern Python 0 05-28-2010 12:13 AM
RE: How to get xml.etree.ElementTree not bomb on invalid charactersin XML file ? Barak, Ron Python 1 05-05-2010 12:37 AM
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
Beginner: read $array with line breaks line by line Marek Stepanek Perl Misc 12 09-02-2006 10:27 AM



Advertisments