how to write an xml file without dom.ext?

H

hackingKK

Hello all.
I need to create an xml file.
I am using dom.minidom module.
It works fine as long as the xml tree is created.
But I get the import error for dom.ext.
I searched through the python docs but can't find a solution.
I am pritty sure that there is way to write the file to disk without
using the ext module.
Since there are so many software doing this with python 2.6 I am sure it
works.
So can some one tell me if there is a way to avoide ext and prittyprint
and still write a file to the disk?

Happy hacking.
Krishnakant.
 
D

Diez B. Roggisch

hackingKK said:
Hello all.
I need to create an xml file.
I am using dom.minidom module.
It works fine as long as the xml tree is created.
But I get the import error for dom.ext.
I searched through the python docs but can't find a solution.
I am pritty sure that there is way to write the file to disk without
using the ext module.
Since there are so many software doing this with python 2.6 I am sure
it works.
So can some one tell me if there is a way to avoide ext and
prittyprint and still write a file to the disk?

By not using minidom at all.

from xml.etree import ElementTree as et

doc = et.fromstring("<mydoc/>")
print et.tostring(doc)

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top