title: getText between tags with Selenium
body: <p>I'm trying to parse the following XML file so that I can get some attributes. One thing I need to do is verify that the content between tags is not empty. To do this, I though I would be able to use the getText method provided for web elements.</p>
  
  <p>The XML file:</p>
  
  <pre><code>&lt;results&gt;
      &lt;result index="1"&gt;
          &lt;track&gt;
              &lt;creator&gt;Cool&lt;/creator&gt;
              &lt;album&gt;Amazing&lt;/album&gt;
              &lt;title&gt;Awesome and Fun&lt;/title&gt;
          &lt;/track&gt;
      &lt;/result&gt;
  &lt;/results&gt;
  </code></pre>
  
  <p>My code for parsing through and getting what I want is as follows (keep in mind there is more than one result):</p>
  
  <pre><code>boolean result = false;
  
  driver.get(url);
  
  List&lt;WebElement&gt; result_list = driver.findElements(By.xpath(".//result"));
  
  if (result_list.size() == num_results) {
  
  try {
      for (int i = 0; i &lt; result_list.size(); i++) {
      WebElement track = result_list.get(i).findElement(By.xpath(".//track"));
  
      WebElement creator = track.findElement(By.xpath(".//creator"));
              System.out.println(creator.getText());
      track.findElement(By.xpath(".//album"));
      track.findElement(By.xpath(".//title"));
      }
      result = true;
  }
  catch (Exception e) {
      result = false;
  }
  }       
  return result;
  </code></pre>
  
  <p>The problem is that the System.out.println call returns an empty string when there is clearly text between the creator tags. Any help would be greatly appreciated!</p>