This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Surprisingly, I don't think there's any standard way of doing this yet. However, this article by Jeff Ryan from developer.com, found by Googling for "ResultSet to XML" strangely enough, provides a rather succinct generic solution. Remarkably simple.
I dont know what you are developing, but if you use a DB you might want to explore the possibility of letting the database handle XML generation for you. I've recently seen this done in MS SQL Server, and it was incredibly easy to do. Instead of writing Java code, just put the functionality into a SP. Has the added advantage of not needing a new software release of something has to change in retrieval of the resultset etc.