RSS XML Generator
Generate an XML document for an RSS feed.
Minimum of Java 8 required.
For Maven and Maven-compatible dependency managers
Add a dependency to your project with the following co-ordinates:
Check the project releases for a list of available versions. Each release page also includes a downloadable JAR if you want to manually add it to your project classpath.
Create an instance of the
RssXmlGenerator. Then, whenever you need to create
an RSS feed, provide a
Channel (describes the RSS channel and its publishable
items) to the
generate method. You'll also need a
Writer so that the
generated XML has somewhere to go to.
def channel = new Channel( title: 'My Website News and Updates', link: 'http://www.mywebsite.com/', description: 'All of the latest stuff from My Website', image: new Image( url: 'http://www.mywebsite.com/images/website-icon.png', title: 'My Website News and Updates', link: 'http://www.mywebsite.com/' ), items: [ new Item( title: 'My awesome blog post', link: 'http://www.mywebsite.com/blog/awesome' ), ... ] ) def output = new StringWriter() def rssXmlGenerator = new RssXmlGenerator() rssXmlGenerator.generate(channel, output)
The example code above populates the minimum fields required by RSS. There are plenty more properties in the Channel, Image, and Item objects. Check out the RSS spec for all the available properties.
Browse the online groovydocs for all the class and method details here: https://javadoc.io/doc/nz.net.ultraq.rss/rss-xml-generator