1 | zero create personalfeed.demo |
1 2 3 4 | <dependencies> <dependency org="zero" name="zero.core" rev="[1.1+,2.0.0.0["/> <dependency org="zero" name="zero.feed" rev="[1.1+,2.0.0.0["/> </dependencies> |
1 2 3 4 5 6 7 | // set response header "Content-Type" headers.out."Content-Type" = "application/atom+xml" // fetch sohu IT news feed and filter only today zero.feed.FeedFactory.fetch("http://news.sohu.com/rss/it.xml") .after("-P1D") .writeTo(request.writer[]) |
1 2 3 4 5 6 7 8 | // set response header "Content-Type" headers.out."Content-Type" = "application/atom+xml" zero.feed.FeedFactory.aggregate( "http://news.sohu.com/rss/it.xml", "http://rss.sina.com.cn/news/allnews/tech.xml", "http://tech.163.com/special/00091JPQ/rssit.xml") .after("-P1D") .writeTo(request.writer[]) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <html> <head> <script type="text/javascript" src="/dojo/dojo.js"></script> <script type="text/javascript"> dojo.require("dojo.parser"); dojo.require("zero.feed.Feed"); </script> <script type="text/javascript"> function fetchSohuIT() { zero.feed.FeedFactory.fetch("http://news.sohu.com/rss/it.xml") .after("-P1D") .loadAsJSON(function(feed) { var items = feed.entries; var htmlContent = ""; for (var i = 0; i < items.length; i++) { var title = items.title; var link = items.links[0].href; htmlContent += "<a href='" + link + "' target='_blank'>" + title + "</a><br/>"; } dojo.byId("feed").innerHTML = htmlContent; }); } </script> </head> <body> <p>This sample shows how to get resulting feed in JSON format.</p> <button onclick="fetchSohuIT();" dojoType="dijit.form.Button"> load sohu IT news! </button> <div id="feed"></div> </body> </html> |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |