title: how to create nested tags using spark xml
body: <p>I am trying to write a df as a xml file. My problem is how can I perform group by in the xml output.</p>
  
  <p>my input data as a csv file:</p>
  
  <pre><code>user_id|acnt_id|transaction|desc 
  1      |1234|   012345| desc1
  1      |1234|   102345| desc2
  1      |5678|   123454| desc1
  2      |1234|   345672| desc1
  </code></pre>
  
  <p>I am reading the csv file and writing back as a xml file, I want to know how can i specify the nested schema when writing the xml .</p>
  
  <p>currently what i am able to get</p>
  
  <pre><code>&lt;transactions&gt;
    &lt;transaction&gt;
            &lt;user_id&gt;1&lt;/user_id&gt;
            &lt;acnt_id&gt;1234&lt;/acnt_id&gt;
            &lt;transaction&gt;012345&lt;/transaction&gt;
            &lt;desc&gt;desc1&lt;/desc&gt;
    &lt;/transaction&gt;
    &lt;transaction&gt;
            &lt;user_id&gt;1&lt;/user_id&gt;
            &lt;acnt_id&gt;1234&lt;/acnt_id&gt;
            &lt;transaction&gt;102345&lt;/transaction&gt;
            &lt;desc&gt;desc2&lt;/desc&gt;
    &lt;/transaction&gt;
    &lt;transaction&gt;
            &lt;user_id&gt;1&lt;/user_id&gt;
            &lt;acnt_id&gt;5678&lt;/acnt_id&gt;
            &lt;transaction&gt;123454&lt;/transaction&gt;
            &lt;desc&gt;desc1&lt;/desc&gt;
    &lt;/transaction&gt;
    &lt;transaction&gt;
            &lt;user_id&gt;2&lt;/user_id&gt;
            &lt;acnt_id&gt;1234&lt;/acnt_id&gt;
            &lt;transaction&gt;345672&lt;/transaction&gt;
            &lt;desc&gt;desc2&lt;/desc&gt;
    &lt;/transaction&gt;
  &lt;/transactions&gt;
  </code></pre>
  
  <p>Expected o/p</p>
  
  <pre><code>&lt;transactions&gt;
    &lt;transaction&gt;
            &lt;user_id&gt;1&lt;/user_id&gt;
                &lt;acnt_id&gt;1234&lt;/acnt_id&gt;
                    &lt;transaction&gt;012345&lt;/transaction&gt;
                    &lt;desc&gt;desc1&lt;/desc&gt;
                    &lt;transaction&gt;102345&lt;/transaction&gt;
                    &lt;desc&gt;desc2&lt;/desc&gt;
                &lt;acnt_id&gt;5678&lt;/acnt_id&gt;
                    &lt;transaction&gt;123454&lt;/transaction&gt;        
                    &lt;desc&gt;desc1&lt;/desc&gt;
    &lt;/transaction&gt;
    &lt;transaction&gt;
            &lt;user_id&gt;2&lt;/user_id&gt;
              &lt;acnt_id&gt;1234&lt;/acnt_id&gt;
                &lt;transaction&gt;345672&lt;/transaction&gt;
                &lt;desc&gt;desc2&lt;/desc&gt;
    &lt;/transaction&gt;
  &lt;/transactions&gt;
  </code></pre>