title: How to use getElementByXpath and getElementsByXpath correctly?
body: <p>How can I get table 'td' values with CasperJS?</p>
  
  <p>The HTML source looks like than this:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;table id="my_table"&gt;
    &lt;tr id='header'&gt;
      &lt;th&gt;sth_head_name&lt;/th&gt;
      &lt;th&gt;ath_head_name&lt;/th&gt;
      &lt;th&gt;sth_head_name&lt;/th&gt;
      &lt;th&gt;sth_head_name&lt;/th&gt;
      &lt;th&gt;sth_head_name&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
      &lt;td&gt;sth_value&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I'd want to get table values using CasperJS. Firstly, I need to select the rows of table; and then I want to get 'td' values. How can I solve this?</p>
  
  <p>I tried a lot of ways, but those didn't work. My solution would look like something similar that you can see below. Its important, that firstly select 'table_rows'; and then select that's td value inside the for cycle.</p>
  
  <pre class="lang-js prettyprint-override"><code>var table_rows = casper.getElementsByXpath("//table[@id='my_table']/tr[not(@id='header')]");
  
  for (var i = 0; i &lt; table_rows.length; i++) {
    var firstRequiredCell_query = table_rows[j].getElementByXpath("//td[position()=2]");
    var secondRequiredCell_query = table_rows[j].getElementByXpath("//td[position()=4]");
    var firstRequiredCell = firstRequiredCell_query.text;
    var secondRequiredCell = secondRequiredCell_query.text;
  }
  </code></pre>