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.