xml tree writing with ElementTree; prepends elements with ns0

A

Alex van der Spek

When reading a tree and writing it back to a new file all the elements are
prepended with the string ns0:

Why is it prepended and how can I suppress this?

Thanks,
Alex van der Spek
 
A

Alain Ketterlin

Alex van der Spek said:
When reading a tree and writing it back to a new file all the elements are
prepended with the string ns0:

That's a namespace prefix.
Why is it prepended and how can I suppress this?

See http://effbot.org/zone/element-namespaces.htm

I'm not sure you can define the default namespace (i.e., avoid prefixes
on element names). However, any conformant XML processor should have no
problem with the output of ElementTree.

If you're actually producing HTML, then you should say so when calling
tostring(), by giving the appropriate value to the method argument.

-- Alain.
 

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,074
Latest member
StanleyFra

Latest Threads

Top