title: Regarding REST response and XMLElement
body: <p>I have below a REST response which needs to be created in the code:</p>
  
  <pre><code>&lt;sample&gt;
     &lt;tags&gt; 
         &lt;tag&gt;
             &lt;name&gt;ABC&lt;/name&gt;
             &lt;Date&gt;2014-10-14T12:30:05Z&lt;/ingress&gt;
         &lt;/tag&gt;
         &lt;tag&gt;
             &lt;name&gt;DEF&lt;/name&gt;
             &lt;Date&gt;2014-10-14T12:30:05Z&lt;/ingress&gt;
         &lt;/tag&gt;
     &lt;/tags&gt;
  &lt;/sample&gt;
  </code></pre>
  
  <p>However,I am getting </p>
  
  <pre><code>&lt;sample&gt;
      &lt;tags&gt;           
          &lt;name&gt;ABC&lt;/name&gt;
          &lt;Date&gt;2014-10-14T12:30:05Z&lt;/ingress&gt;
      &lt;/tags&gt;
      &lt;tags&gt;
          &lt;name&gt;DEF&lt;/name&gt;
          &lt;Date&gt;2014-10-14T12:30:05Z&lt;/ingress&gt;        
      &lt;/tags&gt;
  &lt;/sample&gt;
  </code></pre>
  
  <p>in the response.Can someone please help me how  the declaration of Java class to get the desired REST response ?</p>
  
  <p>Here is the java code:</p>
  
  <pre><code>@XmlRootElement(name = "sample")
  public class Sample {
      private List&lt;Tag&gt; tags;
  
      @XmlElement(name = "tags")
      public List&lt;Tag&gt; getTags() {
          return tags;
      }
  
      /**
       * @param tags
       *            the tags to set
       */
      public void setTags(List&lt;Tag&gt; tags) {
          this.tags = tags;
      }
  
  }
  
  @XmlRootElement(name = "tag")
  public class Tag {
      private String name;
      private Date date;
  
      /**
       * @return the name
       */
      @XmlElement(name = "name")
      public String getName() {
          return name;
      }
  
      /**
       * @param name
       *            the name to set
       */
      public void setName(String name) {
          this.name = name;
      }
  
      /**
       * @return the date
       */
      @XmlElement(name = "date")
      public Date getDate() {
          return date;
      }
  
      /**
       * @param date
       *            the date to set
       */
      public void setDate(Date date) {
          this.date = date;
      }
  }
  </code></pre>
  
  <p>Thanks</p>