title: Grouping XML elements through JavaScript
body: <p>I have an XML like below.</p>
  <pre><code>&lt;Data&gt;
   &lt;Person&gt;
    &lt;Name&gt;ABC&lt;/name&gt;
    &lt;Transaction&gt;123&lt;/Transaction&gt;
   &lt;/Person&gt;
  
   &lt;Person&gt;
    &lt;Name&gt;ABC&lt;/name&gt;
    &lt;Transaction&gt;999&lt;/Transaction&gt;
   &lt;/Person&gt;
  
   &lt;Person&gt;
    &lt;Name&gt;XYZ&lt;/name&gt;
    &lt;Transaction&gt;123&lt;/Transaction&gt;
   &lt;/Person&gt;
  
  &lt;/Data&gt;
  </code></pre>
  <p>And I am trying to group the XML based on name and produce the output like below</p>
  <pre><code>&lt;Data&gt;
  &lt;Person&gt;
  &lt;Name&gt;ABC&lt;/name&gt;
  &lt;Transaction&gt;123&lt;/Transaction&gt;
  &lt;Transaction&gt;999&lt;/Transaction&gt;
  &lt;/Person&gt;
  
  &lt;Person&gt;
  &lt;Name&gt;XYZ&lt;/name&gt;
  &lt;Transaction&gt;123&lt;/Transaction&gt;
  &lt;/Person&gt;
  
  &lt;/Data&gt;
  </code></pre>
  <p>How do I achieve this through JavaScript. I tried by comparing data value in innerhtml and for loops. But it is getting very complex. Any other viable solutions?</p>
  <p>Thanks.</p>