title: Get value of an XML attribute with Groovy (gpath)
body: <p>Using XmlParser() in groovy.
  See the following code. I need to  print the  value of <em>answer</em> when the value of <em>name</em> is <em>type</em>.</p>
  
  <pre><code>   &lt;root&gt;
          &lt;foo name = 'type' answer  = 'car'/&gt;
          &lt;foo name = 'color' answer = 'red'/&gt;
          &lt;foo name = 'size' answer = 'big'/&gt;
      &lt;/root&gt;
  </code></pre>
  
  <p>I need to do something like this:</p>
  
  <pre><code>def XML = new XmlParser().parseText(XMLstring)
  println XML.root.foo.[where  @name = 'type'].@answer
  </code></pre>