ROME and custom Generator elements

The majority of the articles I’ve seen on using ROME to create Atom and RSS feeds don’t show you how to customize the optional ‘generator’ element that both Atom and RSS support. It’s really easy. I’m assuming that you’ve already created and populated a SyndFeed instance:

SyndFeed feed = ..
WireFeedOutput feedOutput = new WireFeedOutput();
WireFeed wireFeed = feed.createWireFeed();
if (wireFeed.getFeedType().startsWith("atom")) {
  Feed atomFeed = (Feed)wireFeed;
  Generator gen = new Generator();
  gen.setValue("Your Site");
  feedOutput.output(atomFeed, ...);
} else {
  Channel rssFeed = (Channel)wireFeed;
  rssFeed.setGenerator("Your Site 1.0 (");
  feedOutput.output(rssFeed, ...);

Make a decision about which feed you’re going to produce, cast to the appropriate implementation of WireFeed (Channel for RSS and Feed for Atom), and then use the appropriate setters on each of those respective classes.

2 thoughts on “ROME and custom Generator elements”

  1. Thanks for this little write-up. I too found that none of the Rome examples showed how to set the generator and other RSS specific elements.

  2. I’m actually struggling with the reverse problem right now, I’m trying to get the generator value when parsing the feed. The code is pretty much the reverse of your example :

    WireFeedInput input = new WireFeedInput();

    XmlReader reader = new XmlReader(new URL(feedUrl));
    WireFeed feed =;

    String generator = null;

    if (feed.getFeedType().startsWith("atom")) {
    Feed atomFeed = (Feed) feed;

    generator = atomFeed.getGenerator().getValue() + " " +
    atomFeed.getGenerator().getVersion() + " (" + atomFeed.getGenerator().getUrl() +
    } else {
    Channel rssFeed = (Channel) feed;
    generator = rssFeed.getGenerator();

    The Atom generator is parsed correctly, but the RSS one comes back null. Any ideas?

Leave a Reply

Your email address will not be published. Required fields are marked *