使用java在RSS feed上创建类别

时间:2016-02-29 12:55:04

标签: java rss rome

我想使用JAVA应用程序(使用ROME)创建RSS提要,并让它工作正常,直到我决定使用某些类别。 我将此代码用于类别

public boolean addRss(String cat,String msg,String msgLink,Date date){
        SyndFeed feed = new SyndFeedImpl();
        List<SyndEntry> entries = new ArrayList<SyndEntry>();
        SyndEntry entry;  
        entry = new SyndEntryImpl();
        entry.setTitle(msg);
        if(msgLink!=null){
            entry.setLink(msgLink);
        }
        List<SyndCategory> categories = new ArrayList<SyndCategory>();
        if(cat!=null){
            SyndCategory category;
            category = new SyndCategoryImpl();
            category.setName(cat);
            categories.add(category);
            entry.setCategories(categories);
            categories.remove(category);
            entries.add(entry);
        }
        entry.setPublishedDate(date);
         entries.add(entry);
         feed.setEntries(entries);
        return true;
    }

但是这不包括输出xml文件中的任何类别标记。 有任何想法吗?感谢

修改
似乎在创建RSS时使用相同的代码(而不是像以前那样创建Item)它确实有效。我现在可以在RSS文件中添加一个类别标记,但它暗示了整个rss feed,即后面的所有项目。所以我不能创建一个包含多个类别项目的RSS订阅源

0 个答案:

没有答案
相关问题