问题
你想从一个简单的XML文档中提取数据。
解决方案
可以使用 xml.etree.ElementTree 模块从简单的XML文档中提取数据。为了演示,假设你想解析Planet Python上的RSS源。下面是相应的代码:
from urllib.request import urlopen
from xml.etree.ElementTree import parse
# Download the RSS feed and parse it
u = urlopen('http://plan
Python可以使用 xml.etree.ElementTree 模块从简单的XML文档中提取数据。 为了演示,假设你想解析Planet Python上的RSS源。下面是相应的代码:
from urllib.request import urlopen
from xml.etree.ElementTree import parse
# Download the RSS feed and parse it
u = urlopen('http://planet.python.org/rss20.x