Problems with ElementTree and ProcessingInstruction

K

Kent Tenney

Howdy,

I want to generate the following file;

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet mystyle?>
<leo_file>stuff</leo_file>

How should I be doing this?

As far as I can tell, ElementTree() requires everything
to be inside the root element (leo_file)

Thanks,
Kent
 
G

Gabriel Genellina

At said:
I want to generate the following file;

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet mystyle?>
<leo_file>stuff</leo_file>

How should I be doing this?

open("filename","w").write('<?xml version="1.0" encoding="utf-8"?>\n'
'<?xml-stylesheet mystyle?>\n'
'<leo_file>stuff</leo_file>\n')

:)
As far as I can tell, ElementTree() requires everything
to be inside the root element (leo_file)

Just keep the first two lines on my example...


--
Gabriel Genellina
Softlab SRL






__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
 
K

Kent Tenney

'<?xml-stylesheet mystyle?>\n'
'<leo_file>stuff</leo_file>\n')

Right.

I can use ElementTree.write('filename') and
prepend the instructions to the resulting file.

It leaves me curious as to the purpose/usage of
ProcessingInstruction()

Thanks,
Kent
 

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,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top