title: Jersey REST Service Output Format
body: <p>I need to format the output (xml) of a restful service using Jersey according to following scenario</p>
  
  <p>I have a class with key value pair as follows.</p>
  
  <pre class="lang-java prettyprint-override"><code>@XmlRootElement(name="columnValues")
  public class KeyValueDTO {
      private String key;
      private String val;
  
      @XmlElement(name="column")
      public String getKey() {
          return key;
      }
  
      @XmlElement(name="value")
      public String getVal() {
          return val;
      }
  }
  </code></pre>
  
  <p>Suppose I have list like this which is returned by rest service:</p>
  
  <pre class="lang-java prettyprint-override"><code>List&lt;KeyValueDTO&gt; mylist = new ArrayList&lt;KeyValueDTO&gt;();
  KeyValueDTO dto1 = new KeyValueDTO();
  dto1.key = "Name";
  dto1.val = "alex";
  
  KeyValueDTO dto2 = new KeyValueDTO();
  dto2.key = "Age";
  dto2.val = 23
  
  mylist.add(dto1);
  mylist.add(dt02);
  </code></pre>
  
  <p>And I want to generate the output as follow</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Name&gt;alex&lt;/Name&gt;
  &lt;Age&gt;20&lt;/Age&gt;
  </code></pre>
  
  <p>But currently it is giving following output</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;column&gt;Name&lt;/column&gt;
  &lt;value&gt;alex&lt;/column&gt;
  &lt;column&gt;Age&lt;/column&gt;
  &lt;value&gt;20&lt;/column&gt;
  </code></pre>
  
  <p>Can anyone let me know how to achieve this?</p>