title: Writing data from objects in java into a xml file
body: <p>I have a piece of code as follows : </p>
  
  <pre><code>    Person person1 = new Person();
      person1.setName("abc");
      person1.setAge(23);
  
      Person person2 = new Person();
      person2.setName("xyz");
      person2.setAge(32);
  </code></pre>
  
  <p>And it needs to re represented in a xml file as :</p>
  
  <pre class="lang-xml prettyprint-override"><code>   &lt;Person&gt;
         &lt;person1&gt;
             &lt;name&gt;abc&lt;/name&gt;
             &lt;age&gt;23&lt;/age&gt;
         &lt;/person1&gt;
         &lt;person2&gt;
             &lt;name&gt;abc&lt;/name&gt;
             &lt;age&gt;23&lt;/age&gt;
         &lt;/person2&gt;
     &lt;/Person&gt;
  </code></pre>
  
  <p>How do I do it?</p>