title: Find specific element position in XPath after checking a condition
body: <p>I have the following html I am working with: (a chunk of it here)</p>
  
  <pre><code>&lt;table class="detailTable"&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td class="detailTitle" align="top"&gt;
          &lt;h3&gt;Credit Limit:&lt;/h3&gt;
          &lt;h3&gt;Current Balance:&lt;/h3&gt;
          &lt;h3&gt;Pending Balance:&lt;/h3&gt;
          &lt;h3&gt;Available Credit:&lt;/h3&gt;
        &lt;/td&gt;
        &lt;td align="top"&gt;
          &lt;p&gt;$677.77&lt;/p&gt;
          &lt;p&gt;$7.77&lt;/p&gt;
          &lt;p&gt;$7.77&lt;/p&gt;
          &lt;p&gt;$677.77&lt;/p&gt;
        &lt;/td&gt;
        &lt;td class="detailTitle"&gt;
          &lt;h3&gt;Last Statement Date:&lt;/h3&gt;
          &lt;h4&gt;Payment Address&lt;/h4&gt;
        &lt;/td&gt;
        &lt;td&gt;
          &lt;p&gt;   05/19/2015  &lt;/p&gt;
          &lt;p class="attribution"&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I need to first check if "<code>Statement Date</code>" exists, and then find its position. Then get it's value which is in a corresponding <code>&lt;p&gt;</code> tag. I need to do this using XPath. Any suggestions?</p>
  
  <p>So far I tried using <code>//table[@class='detailTable'][1]//td[2]//p[position(td[contains(.,'Statement Date')])]</code> but it doesn't work. </p>