1

I want to create an RSS feed using a JAVA application (using ROME), and got it to work OK, till i decided to use some categories. I use this code for the categories

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;
    }

but this doesnt include any category tag on the output xml file. any ideas? thanks

Edit
It seems that using the same piece of code on the creation of the RSS (and not the creation of the Item, as i did before) it does work. I can now add a category tag on the RSS file, but it implies for the whole of the rss feed, i.e for all the items that follows. so i cant create an rss feed that has items from multiple categories

Skaros Ilias
  • 1,008
  • 12
  • 40
  • 1
    Why are you removing the category after adding it? `categories.remove(category);` – janih Mar 22 '16 at 13:06
  • to be honest, i am not so sure, I cant remember. We changed our rss format, so we dont use categories no more, but for the life of me, i cant remember this piece of code.thanks for your input though, this might be a good reason for not working in the first place – Skaros Ilias Mar 22 '16 at 20:32
  • Ok :) because it is possible to have different categories for each item. Your code example probably didn't work because of the remove() -call. – janih Mar 23 '16 at 06:07

0 Answers0