title: Properly iterating through XML with namespaces in Groovy
body: <p>I have the following xml code: </p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
     &lt;soapenv:Body&gt;
        &lt;cms:RelatedConfigurationItemList xmlns:cms="some namespace"&gt;
           &lt;ConfigurationItem&gt;
              &lt;name&gt;data&lt;/name&gt;
              &lt;id&gt;data&lt;/id&gt;
              &lt;type&gt;data&lt;/type&gt;
              &lt;relationship&gt;IS CHILD OF&lt;/relationship&gt;
              &lt;ConfigurationItemList&gt;
                 &lt;ConfigurationItem&gt;
                    &lt;name&gt;data&lt;/name&gt;
                    &lt;id&gt;data&lt;/id&gt;
                    &lt;type&gt;data&lt;/type&gt;
                    &lt;relationship&gt;IS CHILD OF&lt;/relationship&gt;
                    &lt;ConfigurationItemList/&gt;
                 &lt;/ConfigurationItem&gt;
                 &lt;ConfigurationItem&gt;
                    &lt;name&gt;data&lt;/name&gt;
                    &lt;id&gt;data&lt;/id&gt;
                    &lt;type&gt;data&lt;/type&gt;
                    &lt;relationship&gt;IS CHILD OF&lt;/relationship&gt;
                    &lt;ConfigurationItemList/&gt;
                 &lt;/ConfigurationItem&gt;
              &lt;/ConfigurationItemList&gt;
           &lt;/ConfigurationItem&gt;
       &lt;ConfigurationItem&gt;
              &lt;name&gt;other data&lt;/name&gt;
              &lt;id&gt;other data&lt;/id&gt;
              &lt;type&gt;other data&lt;/type&gt;
              &lt;relationship&gt;IS CHILD OF&lt;/relationship&gt;
              &lt;ConfigurationItemList&gt;
                 &lt;ConfigurationItem&gt;
                    &lt;name&gt;other data&lt;/name&gt;
                    &lt;id&gt;other data&lt;/id&gt;
                    &lt;type&gt;other data&lt;/type&gt;
                    &lt;relationship&gt;IS CHILD OF&lt;/relationship&gt;
                    &lt;ConfigurationItemList/&gt;
                 &lt;/ConfigurationItem&gt;
                 &lt;ConfigurationItem&gt;
                    &lt;name&gt;other data&lt;/name&gt;
                    &lt;id&gt;other data&lt;/id&gt;
                    &lt;type&gt;other data&lt;/type&gt;
                    &lt;relationship&gt;IS CHILD OF&lt;/relationship&gt;
                    &lt;ConfigurationItemList/&gt;
                 &lt;/ConfigurationItem&gt;
              &lt;/ConfigurationItemList&gt;
           &lt;/ConfigurationItem&gt;
        &lt;/cms:RelatedConfigurationItemList&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>That I want to validate in Groovy using the following psuedo-code:</p>
  
  <pre><code>def request = testRunner.testCase.getTestStepByName( "relationship_request" )
  def resp = new File('H://test_xml.xml')
  def cms_ns = new groovy.xml.Namespace("namespace for cms",'cms')
  def soap_ns = new groovy.xml.Namespace("http://schemas.xmlsoap.org/soap/envelope/",'soapenv')
  def root = new XmlSlurper().parse(resp)
  
  
  def config_item = root[soap_ns.Envelope][soap_ns.Body][cms_ns.RelatedConfigurationItemList][ConfigurationItem]
  
  config_item.each{
      it.name.each{
          it == corresponding value in db?
          else
          die
      }
  }
  </code></pre>
  
  <p>But I can't seem to get the syntax, logic right for trying to validate values defined (such as name) against a database response. If the config_item declaration is correct, then maybe I have a poor understanding of Groovy closures. Also, I'm not sure if XML slurper or parser is more appropiate and can't quite nail down what exactly the differences are. Hope this is an adequate description of the problem.</p>