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:
当xml.dom.minidom解析一段xml时,它会自动将转义字符转换为大于或小于其可视化表示形式。例如:
>>> import xml.dom.minidom
>>> s = "<example>4 < 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?
有谁知道如何阻止minidom这样做?
1 个解决方案
#1
>>> import xml.dom.minidom
>>> s = "<example>4 < 5</example>"
>>> x = xml.dom.minidom.parseString(s)
>>> x.firstChild.firstChild.toxml()
u'4 < 5'
#1
>>> import xml.dom.minidom
>>> s = "<example>4 < 5</example>"
>>> x = xml.dom.minidom.parseString(s)
>>> x.firstChild.firstChild.toxml()
u'4 < 5'