I use this ugliness to prevent a lot of code duplication in the open and close methods due to the fact that ElementTree refuses to create an open tag without the corresponding close, and vice-versa.

I agree it's a bit weird. I'll give some thought this morning on refactoring it.