ElementTree ; change namespace

Benjamin Watine watine at cines.fr
Wed Oct 7 17:21:10 CEST 2009


Hello the list,

I have question about ElementTree module, I didn't find a specific list 
so I post here. I hope I'm not wrong.

I would like to know how to change the namespace URI of all the Element 
of my XML tree without changing anything else.

I want that because I have to compare 2 XML trees, so I walk trought the 
first tree, and each time I found an element, I delete it (with the 
Element.remove() function) on the second tree. This way, I can see if 
there is remaining or lacking elements in my second tree.
The problem is that my two trees may not have the same namespace, so the 
Element.remove() function doesn't work. That's why I want to change the 
namespace.

Also, The Element.remove() documentation says it compares element with 
their identity ; what is exactly an element identity ?

Thank you,

Ben




More information about the Python-list mailing list