jQuery RSS parsing issue with Delicious feed
I'm trying to parse my delicious links feed to generate custom html. I was not able to parse the item.link and item.creator (index 3,4 of the following rss).
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>ht开发者_JAVA技巧tp://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>
here is my jQuery code, i take rss input from textarea with id "rss" and trying to print the link in firebug console.
feed = $('#rss').val();
$(feed).find('item').each(function(){ console.log($(this).children().eq(3).text());
});
For some reason the complete xml is not rendered correctly, here is the pastebin link of delicious feed http://pastebin.com/KbDNyL0P
Update: It seems that I was using some wrong version/distro of jQuery, I copied jQuery from a plugin directory that causes the issue. Lesson learnt: always download from jQuery/GoogleCode site.
Try using 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);
});
}
});
精彩评论