beautifulsoup分析html非常方便,但xml却不怎么样
推荐使用自带的xml的etree分析
import xml.etree.ElementTree as ET
root = ET.fromstring('''''')
root[0].items()
# coding:utf8
from BeautifulSoup import BeautifulSoup
axml = ''''''
soup = BeautifulSoup(axml)
for s in soup.findAll('dd',{'key':"d1"}):
print s.get('value').encode('utf8')
运行结果:
大一
[Finished in 0.1s]