Building an XML response with Jersey

Jennilelane

New Member
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, 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:\[code\]<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>\[/code\]My issue arises in that there are a variable number of \[code\]<d>\[/code\] and \[code\]<row>\[/code\] elements, which will be determined based on the data passed in. I know that I can format a simple table with \[code\]@XmlRootElement\[/code\] above the class which handles the data, but this may only be useful for my \[code\]<root-element>\[/code\] since the element only gets populated with other elements. I know I'll need to use some sort of loop to create each \[code\]<row>\[/code\], but I'm not sure how I can create each \[code\]<d>\[/code\] element with different data in each field. Any suggestions?
 
Back
Top