Implement RSS in Java

Source: Internet
Author: User
RSS is a standard XML file. The RSS reader can read this XML file to obtain information about the article, so that users can read the blog through the RSS reader instead of the browser, we only need to dynamically generate this XML file. Rsslibj is a small and practical Java library dedicated to reading and generating RSS. The size of rsslibj is only 25 kb. Rsslibj-1_0RC2.jar? Group_id = 71153 & use_mirror = nchc & filename = rsslibj-1_0RC2.jar & 27763931 exml. jar: http://rsslibj.cvs.sourceforge.net/rsslibj/rsslibj/lib/EXML.jar? After downloading view = log, change the expanded name. Zip to. jar.
import com.rsslibj.elements.Channel;public class Writer {    public static void main(String[] args)             throws InstantiationException, ClassNotFoundException,             IllegalAccessException {        Channel channel=new Channel();        channel.setDescription("This is my sample channel.");        channel.setLink("http://localhost/");        channel.setTitle("My Channel");        channel.setImage("http://localhost/",                 "The Channel Image",                 "http://localhost/foo.jpg");        channel.setTextInput("http://localhost/search",                 "Search The Channel Image",                 "The Channel Image",                 "s");        channel.addItem("http://localhost/item1",                "The First Item covers details on the first item>",                "The First Item")                .setDcContributor("Joseph B. Ottinger");        channel.addItem("http://localhost/item2",                "The Second Item covers details on the second item",                "The Second Item")                .setDcCreator("Jason Bell");        System.out.println("The feed in RDF: "+channel.getFeed("rss"));    }}
Channel channel = new channel (); channel. setdescription (account. getdescription (); baseurl = baseurl. substring (0, n); channel. setlink ("http: // server-name/home. c? Accountid = "+ accountid); channel. settitle (account. gettitle (); list Articles = facade. getarticles (accountid, account. getmaxperpage (), 1); iterator it = articles. iterator (); While (it. hasnext () {Article article = (Article) it. next (); channel. additem ("http: // server-name/article. c? ArticleID = "+ article. getarticleid (), article. getsummary (), article. gettitle ();} // output XML: response. setcontenttype ("text/XML"); printwriter PW = response. getwriter (); PW. print (channel. getfeed ("RSS"); PW. close ();

 

This article from the "sorrow of frost" blog, source http://maomao.blog.51cto.com/115985/22180

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.