Hi, I have just recently started using XPath and have run into a problem I can't solve.
I am trying to get the row that some inputted text is in. The Xpath expression and the code I am testing it on are shown below. The first part of the expression returns the td element that contains "identifying text", but when I add the ancestor::tr part it returns nothing. Any help would be appreciated.
xpath=//*[contains(text(),'identifying text')]/ancestor::tr
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
<html xmlns=" >
<head><title>
Untitled Page
</title></head>
<body>
<form name="form1" method="post" action="page1.aspx" id="form1">
<div>
<table id="table1" cols="3">
<tr>
<td style="width: 140px">
identifying text</td>
<td style="width: 122px">
<input name="TextBox2" type="text" id="TextBox2" /></td>
<td style="width: 154px">
</td>
</tr>
</table>
</div>
<div>
</div></form>
</body>
</html>
I am trying to get the row that some inputted text is in. The Xpath expression and the code I am testing it on are shown below. The first part of the expression returns the td element that contains "identifying text", but when I add the ancestor::tr part it returns nothing. Any help would be appreciated.
xpath=//*[contains(text(),'identifying text')]/ancestor::tr
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
<html xmlns=" >
<head><title>
Untitled Page
</title></head>
<body>
<form name="form1" method="post" action="page1.aspx" id="form1">
<div>
<table id="table1" cols="3">
<tr>
<td style="width: 140px">
identifying text</td>
<td style="width: 122px">
<input name="TextBox2" type="text" id="TextBox2" /></td>
<td style="width: 154px">
</td>
</tr>
</table>
</div>
<div>
</div></form>
</body>
</html>