I have the following HTML , see at the end of this question.
Please suggest an XPath expression to return all the top level Parent rows only, i.e. all the tr elements , there should not be any tr element containing the "Child Rows"
Next, I need XPATH query to return the <a href> tags. In my example, it should return the <a href> tag with "FailedStep 1" text
Lastly I also need an XPATH query to return read the "FailedStep 1" table and return data row having "Fail" in it. Refer the "Result" column
I am reading below HTML file in a winforms application. My HTML is below-
Please suggest an XPath expression to return all the top level Parent rows only, i.e. all the tr elements , there should not be any tr element containing the "Child Rows"
Next, I need XPATH query to return the <a href> tags. In my example, it should return the <a href> tag with "FailedStep 1" text
Lastly I also need an XPATH query to return read the "FailedStep 1" table and return data row having "Fail" in it. Refer the "Result" column
I am reading below HTML file in a winforms application. My HTML is below-
Code:
<table align="center" border="1"> <tr> <td> Parent Row 1 </td> </tr> <tr> <td> Parent Row 2 </td> </tr> <tr> <td> Parent Row 3 <table> <thead> <tr> <td class="style4"> Child Row 1 </td> </tr> </thead> <tbody> <tr> <td class="style4"> <a href="http://bytes.com/submit/g/#FailedStep1">1</a> </td> </tr> </tbody> </table> </td> </tr> <tr> <td> Parent Row 4 <table> <tr> <td> <a name="FailedStep1"><b>Failed Step #1</b></a> </td> </tr> <tr> <td> <table> <tr> <td> <a name="FailedStep2">Failed Step </a>header </td> </tr> </table> <br /> <a name="FailedStep3"><b>Failed Step</b></a> <strong>Results</strong> </td> </tr> <tr> <td> <table> <thead> <tr> <td class="style1"> <strong>Operation</strong> </td> <td class="style2"> <strong>Expected Column</strong> </td> <td class="style3"> <strong>Actual Column</strong> </td> <td class="resultRowColumnLabel"> <strong>Result</strong> </td> </tr> </thead> <tbody> <tr> <td class="style1"> Operation 1 </td> <td class="style2" align="center"> <table cellspacing="2"> <tr> Expected Data </tr> </table> Expected Data </td> <td class="style3" align="center"> Actual Data </td> <td class="resultRowPass" align="center"> Pass<table cellspacing="2"> <tr /> </table> </td> </tr> <tr> <td class="style1"> Operation 2 </td> <td class="style2" align="center"> <table cellspacing="2"> <tr> <td class="resultinfo"> Expected Data </td> </tr> </table> </td> <td class="style3" align="center"> <table cellspacing="2"> <tr> 5.6</tr> </table> Actual Data </td> <td class="resultRowFail" align="center"> Fail<table cellspacing="2"> <tr> <br /> <br /> <b>Reason:</b><br /> (Compare Mismatch) </tr> </table> </td> </tr> <tr> <td class="style1"> Operation 3 </td> <td class="style2" align="center"> <table cellspacing="2"> <tr> <td class="resultinfo"> Expected Data </td> </tr> </table> </td> <td class="style3" align="center"> Actual Data </td> <td class="resultRowPass" align="center"> Pass<table cellspacing="2"> <tr /> </table> </td> </tr> </tbody> </table> </td> </tr> </table> </td> </tr> <tr> <td> Parent Row 5 <table> <tr> <td> <a name="PassedStep2"><b>Passed Step #2</b></a> </td> </tr> <tr> <td> <table> <tr> <td> <a name="FailedStep2">Passed Step </a>header </td> </tr> </table> <br /> <a name="FailedStep3"><b>Passed Step</b></a> <strong>Results</strong> </td> </tr> <tr> <td> <table> <thead> <tr> <td class="style1"> <strong>Operation</strong> </td> <td class="style2"> <strong>Expected Column</strong> </td> <td class="style3"> <strong>Actual Column</strong> </td> <td class="resultRowColumnLabel"> <strong>Result</strong> </td> </tr> </thead> <tbody> <tr> <td class="style1"> Operation 1 </td> <td class="style2" align="center"> <table cellspacing="2"> <tr> Expected Data </tr> </table> Expected Data </td> <td class="style3" align="center"> Actual Data </td> <td class="resultRowPass" align="center"> Pass<table cellspacing="2"> <tr /> </table> </td> </tr> </tbody> </table> </td> </tr> </table> </td> </tr> <tr> <td> Parent Row 6 <table> <tr> <td> <a name="PassedStep3"><b>Passed Step #3</b></a> </td> </tr> <tr> <td> <table> <tr> <td> <a name="FailedStep2">Passed Step </a>header </td> </tr> </table> <br /> <a name="FailedStep3"><b>Passed Step</b></a> <strong>Results</strong> </td> </tr> <tr> <td> <table> <thead> <tr> <td class="style1"> <strong>Operation</strong> </td> <td class="style2"> <strong>Expected Column</strong> </td> <td class="style3"> <strong>Actual Column</strong> </td> <td class="resultRowColumnLabel"> <strong>Result</strong> </td> </tr> </thead> <tbody> <tr> <td class="style1"> Operation 1 </td> <td class="style2" align="center"> <table cellspacing="2"> <tr> Expected Data </tr> </table> Expected Data </td> <td class="style3" align="center"> Actual Data </td> <td class="resultRowPass" align="center"> Pass<table cellspacing="2"> <tr /> </table> </td> </tr> </tbody> </table> </td> </tr> </table> </td> </tr> </table>