title: How to get HTML5 data attribute using xpath?
body: <p>How do I get the first table (table1) using xpath for Webdriver?</p>
  
  <pre><code>&lt;span id="dynamically generated id" data-id="table1"&gt;
    &lt;table&gt;
    ...
    &lt;/table&gt;
  &lt;/span&gt;
  
  &lt;span id="dynamically generated id" data-id="table2"&gt;
    &lt;table&gt;
    ...
    &lt;/table&gt;
  &lt;/span&gt;
  </code></pre>
  
  <p>I am able to get all <code>data-id</code> elements but I want to filter within it for text <code>table1</code> to get the exact element.</p>
  
  <p>This did not work!</p>
  
  <pre><code>driver.findElement(By.xpath("//@*[starts-with(name(),'data-id') [contains(text(),'table1')]]")); 
  </code></pre>