Issue 2647: XML munges apos entity in tag content (original) (raw)

I would like it to leave my ' alone, just like it does with my < and >

Python 2.5.1 (r251:54863, Sep 21 2007, 22:46:31) [GCC 4.2.1 (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information.

from xml.dom import minidom doc = minidom.parseString("<a'b>") doc.toxml() u'<a'b>'

That's not a bug. The two XML documents are completely equivalent. If you rely on the lexical representation of specific characters, you should reconsider your usage of XML. toxml could have chosen to represent < as <, and that still would have been correct (IOW, it doesn't even know anymore that you represented it as < in the input).