title: Groovy XmlSlurper access attribute value in root node
body: <p>I'm trying to accomplish accessing the attributes that are part of the root node using Groovy and XmlSlurper.  I can do this easily with nested nodes, but can't seem to access the root node.</p>
  
  <p>Here is the XML structure (simplified):</p>
  
  <pre><code>&lt;coverage lines-covered="2353" lines-valid="2943"&gt;
      &lt;sources /&gt;
      &lt;packages /&gt;
  &lt;/coverage&gt;
  </code></pre>
  
  <p>I'd like to be able to get to the lines-covered and lines-valid attribute values.  Here is the code I'm trying out:</p>
  
  <pre><code>def cobertura = new XmlSlurper().parse(xml)
  def coverage = cobertura.coverage
  def lines = cobertura.find { it.@lines-covered }
  println lines
  </code></pre>
  
  <p>I've also tried:</p>
  
  <pre><code>def cobertura = new XmlSlurper().parse("cobertura-coverage.xml")
  def coverage = cobertura.coverage
  println coverage.@lines-covered
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>def cobertura = new XmlSlurper().parse("cobertura-coverage.xml")
  println cobertura.@lines-covered
  </code></pre>