本文介绍了Python中的XML解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用python解析一个简单的小型XML文件,但是在pyXML上的工作似乎已经停止了.如果可能的话,我想使用python 2.6.谁能推荐可以与2.6兼容的XML解析器?
I'd like to parse a simple, small XML file using python however work on pyXML seems to have ceased. I'd like to use python 2.6 if possible. Can anyone recommend an XML parser that will work with 2.6?
谢谢
推荐答案如果它又小又简单,则只需使用标准库:
If it's small and simple then just use the standard library:
from xml.dom.minidom import parse doc = parse("filename.xml")这将返回实现标准文档对象模型API
如果以后需要执行诸如模式验证或XPath查询之类的复杂操作,那么我建议第三方 lxml模块,它是流行的libxml2 C库的包装.
If you later need to do complex things like schema validation or XPath querying then I recommend the third-party lxml module, which is a wrapper around the popular libxml2 C library.
更多推荐
Python中的XML解析
发布评论