我正在尝试读取XML,但它返回了错误的格式。XML结构是正确的,但在其中一个值中,我有一个backscape (ascii中的代码8)示例:
xml = '<?xml version="1.0" encoding="UTF-8"?><test versao="1.0"><is_apply>0</is_apply><result>some value in xml (heres goes the backspace value) will be wrong</result></test>'
try:
doc = parseString(xml)
except Exception, e:
raise XMLErrorUtils(e, u'Falha ao realizar o parse do xml.')有什么解决方案吗?
发布于 2013-11-08 04:08:23
ASCII 8不是XML中的有效字符。Here's the relevant section of the spec。
如果需要XML中字符,则应该使用a character reference - 
发布于 2015-10-22 16:42:08
小心使用!!
我尝试过用火狐和Notepad++打开这些xml文件。两者在声明无效时是同步的,但都不存在打开/解析的问题
<?xml version="1.0" encoding="UTF-8"?>
<contact></contact>
<?xml version="1.0" encoding="UTF-8"?>
<contact>	</contact>输出:
XML Parsing Error: reference to invalid character number
Location: file:///charcode8.xml Line Number 2, Column 10 https://stackoverflow.com/questions/19842715
复制相似问题