Python: stopping miniDOM from expanding escape sequences

When xml.dom.minidom parses the xml snippet, it automatically converts the escaped characters for larger and smaller than their visual representation. For instance:

>>> import xml.dom.minidom  
>>> s = "<example>4 &lt; 5</example>"
>>> x = xml.dom.minidom.parseString(s)
>>> x.firstChild.firstChild.data
u'4 < 5'

      

Does anyone know how to stop mini-humor from doing this?

0


a source to share


1 answer


>>> import xml.dom.minidom
>>> s = "<example>4 &lt; 5</example>"
>>> x = xml.dom.minidom.parseString(s)
>>> x.firstChild.firstChild.toxml()
u'4 &lt; 5'

      



+3


a source







All Articles