Top.Mail.Ru
Python
? ?
LiveJournal for python.
View:Personal Journal.
View:Friends.
View:Calendar.
Missed some entries? Then simply jump to the previous day or the next day.

Sunday, February 20th, 2005

Subject:Python xml formatting
Time:11:13 pm.
I had e-mail python-help about this but I didn't get a definitive answer:

xml.dom.minidom.parseString(xml.dom.minidom.parseString("<account>willis</account>").toxml("UTF-8")).getElementsByTagName("account")[0].childNodes[0].data
= u'willis'

xml.dom.minidom.parseString(xml.dom.minidom.parseString("<account>willis</account>").toprettyxml(" ","\n","UTF-8")).getElementsByTagName("account")[0].childNodes[0].data =
u'\n willis\n'

I'd like to understand why toprettyxml actually outputs xml that is parsed back as different from the original string.

I'm trying to mesh a rather large xml construct with a gaim xml configuration file, and I need to find a function to print it out so it can be written to the file. toxml() would work except it prints everything on one line, which is no good.

basically I'm just look for a way to print xml so that text doesn't have newlines
i.e. the difference between:
<account>willis</account> <-- good
<account>
willis <-- bad
</account>
Comments: Read 7 orAdd Your Own.

LiveJournal for python.

View:User Info.
View:Friends.
View:Calendar.
View:Memories.
Missed some entries? Then simply jump to the previous day or the next day.

Image