Hi,
you can use velocity template to generate the XML.
http://jakarta.apache.org/velocity/docs/developer-guide.html#How%20Velocity%20Works
An example code is as follows:
***********************************************
1. create a velocity template (Rss.vm)
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:content="http://purl.org/rss/1.0
/modules/content/">
<channel>
<title>$title</title>
<link></link>
<description>$description</description>
<ttl>60</ttl>
<language>en-us</language>
<pubDate>$publishDate</pubDate>
<lastBuildDate>$buildDate</lastBuildDate>
<docs />
<content:encoded>
<![CDATA[
#foreach ( $rssItem in $rssItems)
><item>
<title>$rssItem.title</title>
<link>$rssItem.link</link>
<description>$rssItem.subTitle</description>
<pubDate>$publishDate</pubDate>
</item>
#end
]]>
</content:encoded>
</channel>
</rss>
2. create a servlet which extends VelocityServlet, and
SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z");
context.put("publishDate",sdf.format(new Date()));
context.put("buildDate",sdf.format(new Date()));
context.put("rssItems",rssItems);
context.put("title",rssTitle);
context.put("description",rssDescription); //wat ever u want in the template
//Retrieve the Template
template = getTemplate("Rss.vm");
//set the response type to xml
response.setContentType("text/xml");
PrintWriter writer = response.getWriter();
//'Merge' the template and data to produce the ouput.
StringWriter sw = new StringWriter();
template.merge( context, sw );
//write the output to response
writer.write(sw.toString());
***********************
Hope this helps.
VC.