title: How to convert xml to json in Groovy?
body: <p>In groovy I have the below xml</p>
  
  <pre><code>&lt;data&gt;
     &lt;row&gt;
        &lt;id&gt;USA&lt;/id&gt;
        &lt;value&gt;United States of America&lt;/value&gt;
     &lt;/row&gt;
     &lt;row&gt;
        &lt;id&gt;CAN&lt;/id&gt;
        &lt;value&gt;Canada&lt;/value&gt;
     &lt;/row&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>I need to transform the above xml in groovy to the below json format</p>
  
  <pre><code>{
     "data": [
        {
           "KEY": "USA",
           "VALUE": "United States of America"
        },
        {
           "KEY": "CAN",
           "VALUE": "Canada"
        }
     ]
  }
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks</p>
  
  <p>Hari</p>