假设我有来自 mediawiki api 的以下 XML 响应。我想找出修改 wiki 主题的最早日期,在本例中是 2005-08-23。我如何解析 xml 以找出答案。我正在使用python顺便说一句。
<?xml version="1.0"?>
<api>
<query-continue>
<revisions rvcontinue="46214352" />
</query-continue>
<query>
<pageids>
<id>2516600</id>
</pageids>
<pages>
<page pageid="2516600" ns="0" title="!Kung language">
<revisions>
<rev timestamp="2005-08-23T00:58:40Z" />
<rev timestamp="2005-08-23T01:01:00Z" />
<rev timestamp="2005-09-02T07:21:37Z" />
<rev timestamp="2005-09-02T07:24:28Z" />
<rev timestamp="2006-01-06T07:45:35Z" />
<rev timestamp="2006-03-22T09:03:23Z" />
<rev timestamp="2006-03-30T05:50:12Z" />
<rev timestamp="2006-03-30T20:33:22Z" />
<rev timestamp="2006-03-30T20:35:05Z" />
<rev timestamp="2006-03-30T20:37:16Z" />
</revisions>
</page>
</pages>
</query>
</api>
我尝试了以下
revisions = text.getElementsByTagName("revisions")
for x in revisions:
children = x.childNodes
for y in children:
print y.nodeValue
但这所做的只是打印无。