xpath element with second child containing text

Benchmark created by Dan Manastireanu on


Preparation HTML

<table>
<tr>
    <td>Succeded</td>
    <td>File</td>
    <td>Create</td>
    <td>Left->Right</td>
    <td>\Thunderbird\00sqrcu5.default.archive.7z</td>
</tr>
<tr>
    <td>Succeded</td>
    <td>Folder</td>
    <td>Create</td>
    <td>Left->Right</td>
    <td>\Thunderbird\mab</td>
</tr>
<tr>
    <td>Failed</td>
    <td>File</td>
    <td>Create</td>
    <td>Left->Right</td>
    <td>\Thunderbird\mab\abook.mab</td>
</tr>
<tr>
    <td>Failed</td>
    <td>Failed</td>
    <td>File</td>
    <td>Create</td>
    <td>Left->Right</td>
    <td>\Thunderbird\mab\abook.mab</td>
</tr>
</table>
<script>
  var testXpath = function(xpath) {
   var headings = document.evaluate(
   xpath, document, null, XPathResult.ANY_TYPE, null);
   while (a = headings.iterateNext()) {
    console.log(a);
   }
  
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
using parent selector
testXpath("//td[2][contains(text(),'File')]/..");
ready
using having selector
testXpath("//tr[td[2][contains(text(),'File')]]");
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by Dan Manastireanu on