RSS is a standard XML file. The Rss reader can read this XML file to obtain information about the article.
Instead of reading the Blog through a browser, we only need to dynamically generate the XML file. RSSLibJ is a small version dedicated to reading and generating RSS
A Practical Java library with a size of only 25 k can be downloaded from [url] http://sourceforge.net/projects/rsslibj/#/url#rsslibj-
Export 0rc2.jar and the EXMLjar files it requires, and then copy to web/WEB-INF/lib.
Rsslibj-1_0RC2.jar: [url] http://sourceforge.net/project/downloading.php? Group_id = 71153 & use_mirror = nchc & filename = rsslibj-1_0RC2.jar & 27763931 [/url]
EXML. jar: [url] http://rsslibj.cvs.sourceforge.net/rsslibj/rsslibj/lib/EXML.jar? View = log [/url]
After downloading it, 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 = # \ '"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 (); importcom. rsslibj. elements. channel; publicclassWriter {publicstaticvoidmain (String [] args) throwsInstantiationException, ClassNotFoundException, IllegalAccessException {Channelchannel = newChannel (); channel. setDescription ("Thisismysamplechannel. "); channel. setLink ("/"); channel. setTitle ("MyChannel"); channel. setImage ("/", "TheChannelImage", "/foo.jpg"); channel. setTextInput ("/search", "SearchTheChannelImage", "TheChannelImage", "s"); channel. addItem ("/item1", "TheFirstItemcoversdetailsonthefirstitem>", "TheFirstItem "). setDcContributor ("Joseph PHB. ottinger "); channel. addItem ("/item2", "TheSecondItemcoversdetailsontheseconditem", "TheSecondItem "). setDcCreator ("JasonBell"); System. out. println ("ThefeedinRDF:" channel. getFeed ("rdf "));}}