XML 解析给我空值

发布于 2024-09-10 13:28:50 字数 319 浏览 3 评论 0原文

无法使其正常工作。奇怪的是,我在 Delicious 中有 10 个书签,它打印出 10 个空白字符串,所以它一定接近工作了。

import urllib
from xml.dom.minidom import parse

FEED = 'http://feeds.delicious.com/v2/rss/migrantgeek'

dom = parse(urllib.urlopen(FEED))

for item in dom.getElementsByTagName('item'):
    print item.getAttribute('title')

Having trouble getting this to work. What's strange is that I have 10 bookmarks in Delicious and it prints out 10 blank strings so it must be close to working.

import urllib
from xml.dom.minidom import parse

FEED = 'http://feeds.delicious.com/v2/rss/migrantgeek'

dom = parse(urllib.urlopen(FEED))

for item in dom.getElementsByTagName('item'):
    print item.getAttribute('title')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

假装爱人 2024-09-17 13:28:50

标题不是一个属性,它是项目中的另一个标签。

Title isn't an attribute, it's another tag within item.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文