I need to select node which has a specific value:
<td class='formlabel'>Name:</td>
So I have something like this:
HtmlNode selectedNote = html.DocumentNode.SelectSingleNode("//td[@class='formlabel'][starts-with(., 'Name:')]");
This works. But the problem is that this is a selection with starts-with so for example if I have code like this:
<td class='formlabel'>Name: some text</td>
It will also select the node. I need something that will select node only if this exists
<td class='formlabel'>Name:</td>
So it will select node which has only innerText equals "Name:"
Hmm...Is this possible. Thank you very much.
I believe you want:
HtmlNode selectedNote = html.DocumentNode.SelectSingleNode("//td[@class='formlabel'][text()='Name:']");
Or
HtmlNode selectedNote = html.DocumentNode.SelectSingleNode("//td[@class='formlabel'][.='Name:']");