使用Delicious feed的jQuery RSS解析问题

时间:2010-11-04 20:52:24

标签: jquery parsing rss delicious-api

我正在尝试解析我的美味链接Feed以生成自定义HTML。我无法解析item.link和item.creator(以下rss的索引3,4)。

Delicious/myusername http://www.delicious.com/myusername bookmarks posted by myusername

<item>
  <title>Full-function Core Data example app « Peter McIntyre</title>
  <pubDate>Mon, 11 Nov 2005 04:02:00 -0730</pubDate>
  <guid isPermaLink="false">http://www.delicious.com/url/8b20ab1d1fa021f744acb67f69e22a36#myusername</guid>
  <link>http://petermcintyre.wordpress.com/2010/02/24/full-function-core-data-example-app/</link>
  <dc:creator><![CDATA[myusername]]></dc:creator>
  <comments>http://www.delicious.com/url/8b20ab1d1fa021f744acb67f69e22a36</comments>
  <wfw:commentRss>http://feeds.delicious.com/v2/rss/url/8b20ab1d1fa021f744acb67f69e22a36</wfw:commentRss>
  <source url="http://feeds.delicious.com/v2/rss/myusername">myusername's bookmarks</source>
  <category domain="http://www.delicious.com/myusername/">iphone,</category>
  <category domain="http://www.delicious.com/myusername/">coredata,</category>
</item>
<item>
  <title>Is there a high-level gestures library for iPhone development? - Stack Overflow</title>
  <pubDate>Fri, 24 Sep 2008 09:19:16 +0730</pubDate>
  <guid isPermaLink="false">http://www.delicious.com/url/5082a6b90d2dfecbf9673c3f61e45abc#myusername</guid>
  <link>http://stackoverflow.com/questions/907512/is-there-a-high-level-gestures-library-for-iphone-development</link>
  <dc:creator><![CDATA[myusername]]></dc:creator>
  <comments>http://www.delicious.com/url/5082a6b90d2dfecbf9673c3f61e45abc</comments>
  <wfw:commentRss>http://feeds.delicious.com/v2/rss/url/5082a6b90d2dfecbf9673c3f61e45abc</wfw:commentRss>
  <source url="http://feeds.delicious.com/v2/rss/myusername">myusername's bookmarks</source>
  <category domain="http://www.delicious.com/myusername/">iPhone</category>
  <category domain="http://www.delicious.com/myusername/">gesture</category>
  <category domain="http://www.delicious.com/myusername/">objc</category>
  <category domain="http://www.delicious.com/myusername/">gesture-recognization</category>
</item>

<item> <title>Full-function Core Data example app « Peter McIntyre</title> <pubDate>Mon, 11 Nov 2005 04:02:00 -0730</pubDate> <guid isPermaLink="false">http://www.delicious.com/url/8b20ab1d1fa021f744acb67f69e22a36#myusername</guid> <link>http://petermcintyre.wordpress.com/2010/02/24/full-function-core-data-example-app/</link> <dc:creator><![CDATA[myusername]]></dc:creator> <comments>http://www.delicious.com/url/8b20ab1d1fa021f744acb67f69e22a36</comments> <wfw:commentRss>http://feeds.delicious.com/v2/rss/url/8b20ab1d1fa021f744acb67f69e22a36</wfw:commentRss> <source url="http://feeds.delicious.com/v2/rss/myusername">myusername's bookmarks</source> <category domain="http://www.delicious.com/myusername/">iphone,</category> <category domain="http://www.delicious.com/myusername/">coredata,</category> </item> <item> <title>Is there a high-level gestures library for iPhone development? - Stack Overflow</title> <pubDate>Fri, 24 Sep 2008 09:19:16 +0730</pubDate> <guid isPermaLink="false">http://www.delicious.com/url/5082a6b90d2dfecbf9673c3f61e45abc#myusername</guid> <link>http://stackoverflow.com/questions/907512/is-there-a-high-level-gestures-library-for-iphone-development</link> <dc:creator><![CDATA[myusername]]></dc:creator> <comments>http://www.delicious.com/url/5082a6b90d2dfecbf9673c3f61e45abc</comments> <wfw:commentRss>http://feeds.delicious.com/v2/rss/url/5082a6b90d2dfecbf9673c3f61e45abc</wfw:commentRss> <source url="http://feeds.delicious.com/v2/rss/myusername">myusername's bookmarks</source> <category domain="http://www.delicious.com/myusername/">iPhone</category> <category domain="http://www.delicious.com/myusername/">gesture</category> <category domain="http://www.delicious.com/myusername/">objc</category> <category domain="http://www.delicious.com/myusername/">gesture-recognization</category> </item>

这是我的jQuery代码,我从textarea输入带有“rss”的rss输入并尝试在firebug控制台中打印链接。

feed = $('#rss').val();

$(feed).find('item').each(function(){ console.log($(this).children().eq(3).text());

由于某种原因,没有正确呈现完整的xml,这里是美味Feed http://pastebin.com/KbDNyL0P

的pastebin链接

更新 似乎我使用了一些错误的jQuery版本/发行版,我从一个导致问题的插件目录中复制了jQuery。获得的经验:始终从jQuery / GoogleCode网站下载。

1 个答案:

答案 0 :(得分:1)

尝试使用json

http://feeds.delicious.com/v2/json/myusername?count=15

$.ajax({
   dataType: 'jsonp',
   data: 'count=15',
   jsonp: 'callback',
   url: 'http://feeds.delicious.com/v2/json/myusername?callback=?',
   success: function (data) {
      $.each(data, function(i,item){
         console.log(item.u);
      });
   }
});