title: Parsing an XML in Groovy through XML Slurper
body: <p>I am having this strange problem of parsing an xml through XMLSlurper in groovy and it shows the size as 0. Cannot figure out why.</p>
  
  <p>My xml file looks like:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
  &lt;sites&gt;
      &lt;site name="OctUK"&gt;
          &lt;property name="warName"&gt;OctUKbuild-Deployable&lt;/property&gt;
      &lt;/site&gt;
      &lt;site name="GbsJP"&gt;
          &lt;property name="warName"&gt;GbsJPbuild-Deployable&lt;/property&gt;
      &lt;/site&gt;
  &lt;/sites&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>findSite("${project.GTA_BUILD_HOME}/platforms/pos/config/pos-sites.xml")
  
  //Passed the path of the xml file to the method below:
  GPathResult findSite(String sitesXml) {
      xmlConfig = new XmlSlurper().parse(new File(sitesXml))  
      def siteGPath = xmlConfig.sites.site.findAll
      // Check that a POS-sites.xml is valid
      assert siteGPath.size() != 0, 'Error: no site found'
      return(siteGPath)
  }
  </code></pre>
  
  <p>The method fails with the error saying Error: no site found, because it is giving the result of siteGPath as 0. Not sure why it is giving the result as 0. It should have the size as 2.</p>
  
  <p>Is there anything wrong I am doing. Any help is much appreciated. I am stuck at this point.</p>