嗨,我无法理解 Python 的 minidom 模块。
我有看起来像这样的xml:
<Show>
<name>Dexter</name>
<totalseasons>7</totalseasons>
<Episodelist>
<Season no="1">
<episode>
<epnum>1</epnum>
<seasonnum>01</seasonnum>
<prodnum>101</prodnum>
<airdate>2006-10-01</airdate>
<link>http://www.tvrage.com/Dexter/episodes/408409</link>
<title>Dexter</title>
</episode>
<episode>
<epnum>2</epnum>
<seasonnum>02</seasonnum>
<prodnum>102</prodnum>
<airdate>2006-10-08</airdate>
<link>http://www.tvrage.com/Dexter/episodes/408410</link>
<title>Crocodile</title>
</episode>
<episode>
<epnum>3</epnum>
<seasonnum>03</seasonnum>
<prodnum>103</prodnum>
<airdate>2006-10-15</airdate>
<link>http://www.tvrage.com/Dexter/episodes/408411</link>
<title>Popping Cherry</title>
</episode>
更漂亮:http ://services.tvrage.com/feeds/episode_list.php?sid=7926
这是我试图从中读取的python代码:
xml = minidom.parse(urlopen("http://services.tvrage.com/feeds/episode_list.php?sid=7926"))
for episode in xml.getElementsByTagName('episode'):
for node in episode.attributes['title']:
print node.data
我无法获取实际的剧集数据,因为我想获取每集的所有数据。我尝试了不同的变体,但我无法让它工作。大多数情况下,我得到了<DOM Element: asdasd>
回报。我只关心每一集里面的数据。
谢谢您的帮助