Java Implementation Web version RSS reader (v) Preliminary completion of reading function

Source: Internet
Author: User

A blog post "Web version RSS reader (iv)--Customizing your own RSS parsing library myrsslib4j", has been shared to make your own RSS parsing library. It's a bit of a shame that it only supports blogs in RSS format. Now I'd like to share with you the other RSS parsing library--myrome based on Rome, which supports Atom and RSS 2 formats perfectly.

Myrome.jar is modified on the basis of Rome, and the main changes are as follows: (View detailed modification instructions)

Modify Getauthor () to return null

Modify Getpublisheddate () to return null

Add interface and method to get article digest

Download Address: http://pan.baidu.com/share/link?shareid=3563208157&uk=1259218556

This topic is to add Myrome to the RssReader, modify the interface, complete the initial access and reading functions. The effect of the implementation is:

According to the different subscription information, load the corresponding icon, so that a glimpse of the source of the subscription

Click on the left of a subscription, in the middle of the page to display a title, time and summary list, separated by horizontal line

Click on a summary message, and in the right content area, display all the content of the article.

Double-click the summary information to open the original article address with a new window.

To get to the next step, please follow my initial success:

Download the Myrome-1.0.jar and copy it to Webroot/web-inf/lib. If you have already quoted Rome-0.2.jar, delete them in advance. Create a new Romereadrss class in the Com.tgb.rssreader.manager package to parse online RSS content.

"Romereadrss.java"

Package Com.tgb.rssreader.manager;  
Import Java.net.URL;  
Import java.net.URLConnection;  
Import Com.sun.syndication.feed.synd.SyndFeed;  
Import Com.sun.syndication.io.SyndFeedInput;  
      
Import Com.sun.syndication.io.XmlReader; 
     /** * RSS Subscription information * * @author Longxuan * */public class Romereadrss {/** * Parse RSS subscription information  
        */Public Syndfeed parseRSS (String rss) {Syndfeed feed = null;  
        feed = null;  
      
            try {urlconnection feedurl = new URL (RSS). OpenConnection (); Because the server masks Java as the client Access RSS, set user-agent feedurl.setrequestproperty ("User-agent", "Mozi lla/4.0 (compatible; MSIE 5.0; Windows NT;  
      
            Digext) ");  
      
            Read RSS feeds XmlReader reader = new XmlReader (Feedurl);  
      
            Syndfeedinput input = new Syndfeedinput (); Get the Syndfeed object, that is, get all the information feeds in the RSS feed = Input.build (readeR);  
        catch (Exception e) {e.printstacktrace ();  
    } return feed; }  
      
}

More Wonderful content: http://www.bianceng.cn/Programming/Java/

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.