Oktay
Oktay

Reputation: 531

XPath query returns null

As you see in the picture an item has subitems which are <th> and <td>. When I query item to get <td>, it returns null. Here is the code: item.SelectSingleNode("td") Shouldn't it get td node? (https://i.sstatic.net/EXu7W.png)

enter image description here

Upvotes: 0

Views: 113

Answers (1)

har07
har07

Reputation: 89295

It seems that <td> isn't direct child of current item. To select descendant that isn't direct child you can use double slashes (//) :

item.SelectSingleNode(".//td")

And if I see it correctly, <td> is child of <th>, so you can also do this way :

item.SelectSingleNode("th/td")

Upvotes: 1

Related Questions