BLOG
Enjoy when you can, and endure when you must.
NOV 26, 2013/Python
解析XML:更优的性能
BeautifulSoup是一个很强大的HTML/XML解析工具,简单易用。不过从性能上来说,它可能并不是最好的。因此,我们考虑使用另外一个第三方包lxml,它在底层是通过C实现的,因此在速度上会有明显的优势。还是之前的例子:<?xml version="1.0" encoding="utf-8"?> <CSubmitState xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www...
NOV 22, 2013/Python
解析XML:ElementTree
解析XML是很常见的需求,利用Python内置的ElementTree XML API即可实现。假如有如下一个简单的XML文档(来自于微信的XML数据包):<xml> <ToUserName>toUser</ToUserName> <FromUserName>fromUser</FromUserName>  <CreateTime>1348831860</CreateTime> <MsgType>text</MsgType> <Content>thi...
1