views:

251

answers:

1

When xml.dom.minidom parses a piece of xml, it automagically converts escape characters for greater than and less than into their visual representation. For example:

>>> 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 minidom from doing this?

+3  A: 
>>> import xml.dom.minidom
>>> s = "<example>4 &lt; 5</example>"
>>> x = xml.dom.minidom.parseString(s)
>>> x.firstChild.firstChild.toxml()
u'4 &lt; 5'
Dave
good call... i should have thought of that. thanks!
flummoxed