hei there, i'm slowly going maaad!

i'm pretty new to xml and i need to convert one structure into a (for me seemingly totally) different one. here's an excerpt of what i'm trying to do:
old xml structure:
Code:
<row>
<forum>forum 1</forum>
<title>topic 1</title>
<date>2009-09-22 15:22:24</date>
<poster>benniii</poster>
<content>content test 1</content>
</row>
<row>
<forum>forum 1</forum>
<title>topic 1</title>
<date>2009-09-23 16:11:22</date>
<poster>thomas</poster>
<content>content test 2</content>
</row>
<row>
<forum>forum 2</forum>
<title>topic 1</title>
<date>2009-09-06 14:36:21</date>
<poster>benniii</poster>
<content>content test 3</content>
</row>
xml structure i'm desperately trying to achieve
Code:
<topic forum="forum 1" title="topic 1">
<message posted="2009-09-22 15:22:24" by="benniii">content test 1</message>
<message posted="2009-09-23 16:11:22" by="thomas">content test 2</message>
</topic>
<topic forum="forum 2" title="topic 1">
<message posted="2009-09-06 14:36:21" by="benniii">content test 3</message>
</topic>
i'd be dyingly gracious for any clue how to get this to work.
if the above is totally misunderstanding, here's a screenshot of the structure i need:
thanks so much,
benni