-1
我是python的新手。我需要來自「title」和「pubDate」元素的文本,但僅限於這些元素的第一個實例。我一直在嘗試使用「lxml」:從xml doc中獲得標題和pubDate元素
tree=etree.parse('doc.xml')
x = tree.findtext("rss/channel/item/title")
y = tree.findtext("rss/channel/item/pubDate")
print x, y
我在輸出中不斷收到無,無。 下面是XML文件:
<rss version="2.0">
<channel>
<title>Dynamic rss from aaaa.aaaa search</title>
<link>http://aaaaa.aaaa.info</link>
<ttl>30</ttl>
<description>RSS feed for selected show/news</description>
<item>
<title>
<![CDATA[ AAAAAAA 7x16 (HDTV-LOL) [VTV] ]]>
</title>
<pubDate>Mon, 13 Feb 2012 00:00:00 GMT</pubDate>
<link>
<![CDATA[
http://torrent.zoink.it/AAAAAAAA.7x16.(HDTV-LOL)[VTV].torrent
]]>
</link>
<description>
<![CDATA[
AAAAAAAA 7x16 (HDTV-LOL) [VTV] - http://torrent.zoink.it/AAAAAAA.7x16.(HDTV-LOL[VTV].torrent
]]>
</description>
-1用於發佈格式不正確的XML。 – 2012-02-21 15:02:01