Should I use PyXML or what's in the standard library?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- Illegal to have multiple roots (start tag in epilo
- How to get the background from multiple images by
- Django __str__ returned non-string (type NoneType)
ElementTree is provided as part of the standard Python libs. ElementTree is pure python, and cElementTree is the faster C implementation:
Here's an example usage, where I'm consuming xml from a RESTful web service:
There's also BeautifulSoup, which has an API some might prefer. Here's an example on how you can extract all tweets that have been favorited from Twitter's Public Timeline:
I always prefer to use the standard library when possible. ElementTree is well known amongst pythonistas, so you should be able to find plenty of examples. Parts of it have also been optimized in C, so it's quite fast.
http://docs.python.org/library/xml.etree.elementtree.html