Attached is a patch for ElementTree (based on a checkout from the SVN trunk's xmlcore.etree) that seems to perform better escaping of cdata and attribute values. Instead of replacing, for example ""e;" with ""e;" or "&" with "&", it tries to avoid requoting ampersands in things that look like entities. Sorry, I haven't tested this with anything except Python 2.4, I'm not quite sure what to do about _encode_entity, and I haven't patched any tests or written a new one for this change. Consider this more of a RFC than a patch ready-for-submission as a result.
Logged In: YES user_id=38376 I'm not sure I follow. ET works on the infoset side of things, where everything is decoded into Unicode strings (or compatible ASCII strings). If you set an attribute to "&" in the infoset, it *must* be encoded on the way out. If you want an ampersand, use "&".