Building an XML response with Jersey
===

I'm attempting to build a Jersey web service which will take in data, format it into an XML document, then pass it to another service. I realize that [Jersey does have XML support][1], but I'm having a bit of trouble implementing it due to the required XML structure for the project. The desired output looks something like this:

    <root-element>
        <table>
            <row>
                <d>data1</d>
                <d>data2</d>
                <d>data3</d>
            </row>
            <row>
                <d>data4</d>
                <d>data5</d>
                <d>data6</d>
            </row>
        </table>
   </root-element>
My issue arises in that there are a variable number of `<d>` and `<row>` elements, which will be determined based on the data passed in. I know that I can format a simple table with `@XmlRootElement` above the class which handles the data, but this may only be useful for my `<root-element>` since the element only gets populated with other elements. I know I'll need to use some sort of loop to create each `<row>`, but I'm not sure how I can create each `<d>` element with different data in each field. Any suggestions?


  [1]: http://jersey.java.net/nonav/documentation/latest/xml.html