Sorry for my little riddle, but you solved it quite good with:

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

and comments are also in ElementTree (xml.etree.ElementTree.Comment)

Thanks

Stefan Behnel schrieb:
Alexander Eisenhuth, 08.07.2010 12:07:
Stefan Behnel schrieb:
Alexander Eisenhuth, 08.07.2010 11:08:
- I've to write a XML document including comments

"write" in the sense of typing in a text editor? Or constructing one
programmatically in memory? Or ... ?

write means write to a file

You seam to imply that it's obvious what you want to do. From the little information that you give us, it's not.


And what kind of data from what kind of source do you want to put into
the document?

Data is present as tags and attributes

Whatever that is supposed to mean in this context.


All of that has an impact on the 'right' answer.

... and it still does.


- the document should be formatted that it could be viewed with a text
editor

What is the fastest (time for realization) approach doing it in
python 2.5?

If you mean to build an XML document programmatically, potentially
using data that you get from somewhere, take a look at cElementTree.
There's also a short recipe for pretty printing the tree before
writing it out.

Is the API of cElementTree different from ElementTree in the python
standard library?

Same thing, different import.

Note that both were updated in Py2.7, BTW.

Stefan

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to