我正在嘗試閱讀我正在獲取的xml Feed,但無法訪問特定元素。我正在使用python,並且python文檔對於我應該使用的內容還不清楚。如何使用python從xml檢索特定元素
這裏是飼料:
<title>More eagle</title>
<summary>http://www.181.fm/winamp.plsstation=181eagle&style=&description=The%20Eagle%20(Classic ...</summary>
<link rel="alternate" href="http://mail.google.com/mail [email protected]&message_id=12995390f36c310b&view=conv&extsrc=atom" type="text/html" />
<modified>2010-07-02T22:13:51Z</modified>
<issued>2010-07-02T22:13:51Z</issued>
<id>tag:gmail.google.com,2004:1340194246143783179 </id>
這裏是我當前的功能:
def parse_xml(feed):
feedxml = minidom.parseString(feed)
name = feedxml.getElementsByTagName('name')
subject = feedxml.getElementsByTagName('title')
contents = feedxml.getElementsByTagName('summary')
return name + "\n" + subject + "\n" + contents
爲了澄清,我需要得到元素標籤之間的文本。現在我收到以下內容: [,] –
SachaK
2010-07-06 17:25:38