浏览 2141 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-08-27
不多说了,看附件中的插件,还剪裁了一个ff only的jquery:) 发现了一个XUL教程 http://developer.mozilla.org/index.php?title=Cn/XUL_%E6%95%99%E7%A8%8B ok,言归正传,Atom解析参见 http://developer.mozilla.org/en/Feed_content_access_API FeedTestResultListener=function(){} FeedTestResultListener.prototype = { handleResult: function(result) { var feed = result.doc; feed.QueryInterface(Components.interfaces.nsIFeed); content=feed.title.text+"\n" var itemArray = feed.items; var numItems = itemArray.length; var i; var theEntry; var info; for (i=0; i<numItems; i++) { theEntry = itemArray.queryElementAt(i, Components.interfaces.nsIFeedEntry); if (theEntry) { if(theEntry.link) content += theEntry.link.resolve("")+"\n" if(theEntry.title.text) content += theEntry.title.text if (theEntry.summary) info = theEntry.summary.text else info = theEntry.content.text content+=info+"\n" } } alert(content) } } function fetch(url,listener){ $.get(url,{},function (data) { var ioService = Components.classes['@mozilla.org/network/io-service;1'] .getService(Components.interfaces.nsIIOService); var uri = ioService.newURI(url, null, null); var parser = Components.classes["@mozilla.org/feed-processor;1"] .createInstance(Components.interfaces.nsIFeedProcessor); try { parser.listener = listener; parser.parseFromString(data, uri); }catch(e) { alert("Error parsing feed."); } },"text") } fetch("http://api.douban.com/people/zuroc/miniblog",new FeedTestResultListener())[/size] 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |