title: Parse XML using Groovy and XmlSlurper and iterate the tags
body: <p>I am able to parse XML through HTTP URL by using Groovy and XmlSlurper and output the values associated to tags. Below is the generated sample XML page. </p>
  
  <pre><code>&lt;worklog&gt;
     &lt;worklog_id&gt;10100&lt;/worklog_id&gt;
     &lt;issue_key&gt;TST-3&lt;/issue_key&gt;
     &lt;hours&gt;2.0&lt;/hours&gt;
     &lt;work_date&gt;2014-01-01&lt;/work_date&gt;
     &lt;work_date_time&gt;2014-01-01 00:00:00&lt;/work_date_time&gt;
     &lt;username&gt;admin&lt;/username&gt;
     &lt;reporter&gt;admin&lt;/reporter&gt;
  &lt;/worklog&gt;
  &lt;worklog&gt;
     &lt;worklog_id&gt;10200&lt;/worklog_id&gt;
     &lt;issue_key&gt;TST-3&lt;/issue_key&gt;
     &lt;work_date&gt;2014-01-02&lt;/work_date&gt;
     &lt;work_date_time&gt;2014-01-02 00:00:00&lt;/work_date_time&gt;
     &lt;username&gt;admin&lt;/username&gt;
     &lt;reporter&gt;admin&lt;/reporter&gt;
  &lt;/worklog&gt;
  &lt;worklog&gt;
     &lt;worklog_id&gt;10201&lt;/worklog_id&gt;
     &lt;issue_key&gt;TST-3&lt;/issue_key&gt;
     &lt;hours&gt;0.25&lt;/hours&gt;
     &lt;work_date&gt;2014-01-02&lt;/work_date&gt;
     &lt;work_date_time&gt;2014-01-02 10:33:00&lt;/work_date_time&gt;
      &lt;username&gt;admin&lt;/username&gt;
     &lt;reporter&gt;admin&lt;/reporter&gt;
   &lt;/worklog&gt;
  &lt;worklog&gt;
     &lt;worklog_id&gt;10400&lt;/worklog_id&gt;
     &lt;issue_key&gt;TST-3&lt;/issue_key&gt;
     &lt;hours&gt;2.0&lt;/hours&gt;
     &lt;work_date&gt;2014-01-07&lt;/work_date&gt;
     &lt;work_date_time&gt;2014-01-07 12:03:00&lt;/work_date_time&gt;
      &lt;username&gt;admin&lt;/username&gt;
     &lt;reporter&gt;admin&lt;/reporter&gt;
   &lt;/worklog&gt;
  &lt;worklog&gt;
     &lt;worklog_id&gt;10202&lt;/worklog_id&gt;
     &lt;issue_key&gt;TST-4&lt;/issue_key&gt;
     &lt;hours&gt;1.0&lt;/hours&gt;
     &lt;work_date&gt;2014-01-02&lt;/work_date&gt;
     &lt;work_date_time&gt;2014-01-02 15:52:00&lt;/work_date_time&gt;
     &lt;username&gt;admin&lt;/username&gt;
     &lt;reporter&gt;admin&lt;/reporter&gt;
   &lt;/worklog&gt;
  </code></pre>
  
  <p>However, in my XML I need to traverse through my XML and look for the issue_key tags having same value. If there are multiple issue_key tags with same value, as in here "TST-3",
  then I want to collect and consolidate the values associated with hour work_date, work_date_time, username, activity_name, work_description, parent_key, reporter tags for this single issue_key tag and then output it in the same order in which it was generated along with the other tags having different issue_key values.</p>
  
  <p>Sorry for being a completee noob to Groovy and XmlSlurper. But can anybody let me know how to go about it. Also, below is my Groovy code to get the attributes from the XML.</p>
  
  <pre><code>def worklogList = new ArrayList&lt;Worklog&gt;()
      def wklog
      def worklogs = new XmlSlurper().parse(new File("C:\\xml-worklog\\worklog.xml"))
      worklogs.worklog.each {node -&gt;
          wklog = new Worklog();
  
          wklog.work_date = node.work_date
          wklog.work_date_time = node.work_date_time
          wklog.issue_key = node.issue_key
          wklog.hours = node.hours
          wklog.username = node.username
          wklog.reporter = node.reporter
          worklogList.add(wklog)
      }
      worklogList.each {wklogT -&gt; println(wklogT)}
  }
  
  class Worklog
  {
  String issue_key
  String hours
  String work_date
  String work_date_time
  String username
  String activity_name
  String work_descripton
  String reporter
  
      @Override
      public String toString()
      {
          return "Issue Key: ${issue_key} \t Hours: ${hours} \t Work Date: ${work_date} \t Work Date Time: ${work_date_time} \t Username: ${username} \t Reporter: ${reporter} \t Activity Name: ${activity_name} \t Description: ${work_descripton}"
      }
  }
  </code></pre>
  
  <p>And the expected o/p for a particular issue key,let's say <strong>'TST-3'</strong> is - </p>
  
  <hr>
  
  <p>Hours Worked | Work Date | Work Date Time | Username | Reporter | </p>
  
  <hr>
  
  <p>2.0 | 2014-01-01 | 2014-01-01 00:00:00 | admin | admin |</p>
  
  <hr>
  
  <pre><code>| 2014-01-02 | 2014-01-02 00:00:00 | admin | admin |
  </code></pre>
  
  <hr>
  
  <p>0.25| 2014-01-02 | 2014-01-02 10:33:00 | admin | admin |</p>
  
  <hr>
  
  <p>2.0 | 2014-01-07 | 2014-01-02 12:03:00 | admin | admin | </p>
  
  <hr>
  
  <p>How can I get these values in ordered list object for every issue_key attribute.</p>