Ilya Khudyakov
Ilya Khudyakov

Reputation: 311

Get all RSS feed entries with Rome Library

i am using Rome library for Java to parse some RSS. By default it takes 25 entries.

Tell me please, how to get next 25 entries?

My test code is:

public static SyndFeed getSyndFeedForUrl(String url) throws Exception {

    SyndFeed feed = null;
    InputStream is = null;

    try {

        URLConnection openConnection = new URL(url).openConnection();
        is = new URL(url).openConnection().getInputStream();
        if("gzip".equals(openConnection.getContentEncoding())){
            is = new GZIPInputStream(is);
        }
        InputSource source = new InputSource(is);
        SyndFeedInput input = new SyndFeedInput();
        feed = input.build(source);

    } catch (Exception e){
        e.printStackTrace();
    } finally {
        if( is != null) is.close();
    }

    return feed;
}

public static void main(String[] args) {
        SyndFeed feed;
        try {
            feed = getSyndFeedForUrl("http://example.com/rss");
            List res = feed.getEntries();
            for(Object o : res) {
                System.out.println(((SyndEntryImpl) o).getDescription().getValue());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Thank you!

Upvotes: 3

Views: 3902

Answers (1)

janih
janih

Reputation: 2234

When you call feed.getEntries(), Rome library returns all entries that are available in http://example.com/rss. It is not possible to get more than there are in the xml document (unless the entries have been cached in some service like Feedly).

See

Upvotes: 5

Related Questions