Pythonのお勉強 Part16
■ このスレッドは過去ログ倉庫に格納されています
0734デフォルトの名無しさん
2007/01/30(火) 21:15:53ElementTree に XPath は実装されてないよ。
find() なんかの引数に渡せるのは、 'body/div/p' みたいに
要素名をスラッシュで区切った文字列だけだと思ってほぼ問題なし。
root = ET.fromstring(xml)
items = []
for time in root.findall('timeline/time'):
sec = time.find('sec')
comment = time.find('comment')
items.append([float(sec.text), comment.text])
ElementTree 公式のドキュメントと、urllib, urllib2 を調べると吉です。
■ このスレッドは過去ログ倉庫に格納されています