使用python生成或者解析xml的方法用的最多的可能就数python标准库xml.etree.ElementTree和lxml了,在某些环境下使用xml.etree.ElementTree更方便一些,毕竟是python2.5以后的标准库。
没想到的是python标准库中竟然存在这么一个低级的bug,简单来说就是某种情况下使用ElementTree序列化的xml数据竟然无法正常解析。仔细分析之后发现是因为charset的原因,但为何不在序列化的时候就做一些检测,进行相应提醒呢?也不至于出现自己序列化自己却不能正常解析的尴尬局面了吧?这点和lxml相比就差远了。
具体示例如下:

def test_lxml():
from lxml import etree
root = etree.Element('root')
root.text = '123\x0c'
s = etree.tostring(root)
print 's = ', s
tree = etree.fromstring(s)
print tree
def test_elementtree():
from xml.etree.ElementTree import tostring, fromstring, Element
root = Element('root')
root.text = '123\x0c'
s = tostring(root)
print 's = ', s
tree = fromstring(s)
if __name__== '__main__':
test_elementtree()
# test_lxml()

同样的逻辑,如果使用ElementTree来实现的话出现错误如下:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAogAAAD4CAIAAADgloAFAAAeoUlEQVR4nO2dzY7luJGF7+v6gTy99bJfwbPSrtczr2ADDRgwYMPdQC1n0agclcg4PMEfiTfz+xYNJRmMOBGUGHWrUrdf//2///jr//zjL3/5y5/+9KcXAAAA3M63b99++umn33///bfffnvRmAEAAJ6FxgwAALARNGYAAICNoDEDAABsBI0ZAABgI2jMAAAAG0FjBgAA2IhGYz5O9AU4rx3xM53x1PrCnX+8M+5gxBtqtdT/nXsNADCCaszZRlI1eLAxO4Jv1rO0FJHDj1hTenMq9MQQWT/rnGfjPugHAN6RsDFfTrHqj5fjo3rwPduYdbin9CyKG7mdtQWO/3HGvd2jc53/m29LANgNtzFfqDbmV+1MEV3hOFF1XjX2/VT1iNlU3KYecd2siaPHz1frKZfo8WouTamlkyiFZqBBPWWVmuKrIqua/TqYcZuhy8TLqTJlANiZzsYsME+H7PUrOIOap49IZCSuM169FvVxUujIV2geqUOfZieFDnm+z0sKIw6F5u5E/HAjIQBgZ+Y35tfYAXQUlFPabZ+e7r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/VNI0ZAABgHOu7slO9mX9mBgAA6GZmY+4wBgAAgDM0ZgAAgI2Y3JjpygAAACMs+TfmlYIBAAA+M3zzFwAAwEbQmAEAADaCxgwAALARNGYAAICNoDEDAABsBI0ZAABgI2jMAAAAG3FuzP8HvYBkV35a70EAAAAASUVORK5CYII=" alt="" />
如果使用lxml来实现的话错误提示如下:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAosAAAEBCAIAAACfS3hjAAAfT0lEQVR4nO2dwa7kuJFF9bv+II+3XvYvzKy083rmF2zAhg233XAbqOUsCn5QKSIuI0hKYmaeg0ZDSZE3bgT1GJVdma+3//m/v37989//+9ff//73v/nNbzYAAAC4nW/fvv3ud7/797///euvv250aAAAgEWgQwMAAKwIHRoAAGBF6NAAAAArQocGAABYETo0AADAitChAQAAVoQODQAAsCLZDr0f6It0XDuiM53x1PrCHV/eGXcw4g21ulT/zr0GABgh1aGrHcWd8GCHzhi+2c+lpYgEv2JNadKl0BNDVHWuE6/GfVAHAF6Rdoc+HWfuy9M54p6Az3ZoHe4pPxfFjWRnbUFGf5xxtXt8Xqd/82MJAKtR7tAn3A69eYeLaA/7AVfcnZzXcf2Iu6W4TT/iulmTjJ98vtqPXaLH3VyaVq1IlEIz0KAfW6Wmedek6zlfh2TcZmibuL1lUwaAlRnt0ILkMVG93oLDqHkMiURG4mbG3WtRn0wKHfkKzyN16POcSaHDXl7zlMKIoPDcnUg+3EgIAFiZCzv0NnYS7QZ7S8v2+emOq/2419GgtqTFo3y1B5FvJGvvuvOFz2YKyfkjZTnVoU9Q2z4OdtS5Gc6dP5gCAKzAJX8PfaR5AmplrTlyt+MIq56kzRDRYNVn0nPTQ1NBr3WlhE+dgh4ZKUuzDh111s4zazMVyMcdTAEAVmD0s9z7fxAx9gNWpONYaZ6A2lKfHyErwtlYmXCD9YnszdKf4j9/Kz8/EsnE7ahDRLdm0v8xXzduJJX0DwCLcNP3oY8HjThuMuPCSd5kh5+qeTvnND+6tcXHazSnmfJu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/7W9/+8c//tHzWe79P4gY+wEr0tGBqp1gih8hK8LZWJlwg/WJ7M3Sn+I/fwsA4DP53qF//vnnX3755f8BQCfxhyZz3JcAAAAASUVORK5CYII=" alt="" />
可以很容易看出lxml在无效xml字符方面的处理更友善一些,能在赋值的时候就检测字符有效性,而ElementTree则允许用户赋值,并能顺利序列化,但却在解析数据的时候出现异常。
究其根源,是root.text = '123\x0c'赋值中存在无效xml字\x0c,合法xml字符集定义如下:http://www.w3.org/TR/2006/REC-xml-20060816/#charsets

python标准库xml.etree.ElementTree的bug的更多相关文章

  1. [python标准库]XML模块

    1.什么是XML XML是可扩展标记语言(Extensible Markup Language)的缩写,其中的 标记(markup)是关键部分.您可以创建内容,然后使用限定标记标记它,从而使每个单词. ...

  2. python模块:xml.etree.ElementTree

    """Lightweight XML support for Python. XML is an inherently hierarchical data format, ...

  3. [python 学习] 使用 xml.etree.ElementTree 模块处理 XML

    ---恢复内容开始--- 导入数据(读文件和读字符串) 本地文件 country_data.xml <?xml version="1.0"?> <data> ...

  4. python模块之xml.etree.ElementTree

    xml.etree.ElementTree用于解析和构建XML文件 <?xml version="1.0"?> <data> <country nam ...

  5. [python 2.x] xml.etree.ElementTree module

    XML 文件:xmlparse.xml <?xml version="1.0" encoding="UTF-8" standalone="no& ...

  6. Python 标准库之 xml.etree.ElementTree

    Python 标准库之 xml.etree.ElementTree Python中有多种xml处理API,常用的有xml.dom.*模块.xml.sax.*模块.xml.parser.expat模块和 ...

  7. python解析xml文件之xml.etree.cElementTree和xml.etree.ElementTree区别和基本使用

    1.解析速度:ElementTree在 Python 标准库中有两种实现.一种是纯 Python 实现例如 xml.etree.ElementTree ,另外一种是速度快一点的 xml.etree.c ...

  8. Python 标准库、第三方库

    Python 标准库.第三方库 Python数据工具箱涵盖从数据源到数据可视化的完整流程中涉及到的常用库.函数和外部工具.其中既有Python内置函数和标准库,又有第三方库和工具.这些库可用于文件读写 ...

  9. Python标准库之 xml.etree.ElementTree

    Element类型是一种灵活的容器对象,用于在内存中存储结构化数据. 每个element对象都具有以下属性: 1. tag:string对象,表示数据代表的种类. 2. attrib:dictiona ...

随机推荐

  1. 点击a标签,跳转到iframe中,并在iframe中显示指定的页面

    点击a标签,跳转到iframe中,并在iframe中显示指定的页面 1.用a标签的target属性 <iframe id="myFrameId" name="myF ...

  2. LinkedList其实就那么一回事儿之源码分析

    上篇文章<ArrayList其实就那么一回儿事儿之源码分析>,给大家谈了ArrayList, 那么本次,就给大家一起看看同为List 家族的LinkedList. 下面就直接看源码吧: p ...

  3. Objective-C( Foundation框架 一 数组(NSMutableArray))

    NSMutableArray:可变数组 NSMutableArray是NSArray的子类 创建NSMutableArray数组对象 添加数组元素: // 创建数组 NSMutableArray *a ...

  4. spring随手笔记1:constructor-arg

    <bean id="Hello" class="com.ltf.captha.serviceImpl.HelloWorldServiceImpl"> ...

  5. IntelliJ UI安装

  6. Zabbix汉化方法

    1.windows下选择一个汉化字体包 2.拷贝到linux字体目录下 [root@www Desktop]# cd /var/www/html/zabbix/fonts/[root@www font ...

  7. buaaoj230——next_permutation的应用

    题目地址 简单的全排列输出,借用stl中的next_permutation就非常简单了. 关于next_permutation:(备忘,来源网络) /*这是一个求一个排序的下一个排列的函数,可以遍历全 ...

  8. MATLAB 图像处理——Contrast Enhancement Techniques

    Contrast Enhancement Techniques %调整图片尺寸imresizeimages{k} = imresize(images{k},[width*dim(1)/dim(2) w ...

  9. vector 的 push_back[转]

    vector是用数组实现的,每次执行push_back操作,相当于底层的数组实现要重新分配大小(即先free掉原存储,后重新malloc):这种实现体现到vector实现就是每当push_back一个 ...

  10. Python SocketServer源码分析

    1      XXXServer 1.1      BaseSever 提供基础的循环等待请求的处理框架.使用serve_forever启动服务,使用shutdown停止.同时提供了一些可自行扩展的方 ...