Given the following XML document:
<table>
<tr> <td>A</td> <td>B</td> <td>C</td> </tr>
<tr> <td>D</td> <td>E</td> <td>E</td> </tr>
<tr> <td>F</td> <td>G</td> <td>H</td> </tr>
</table>
I get different results for the following expressions and I don’t understand what is the reason for that.
for: //td[parent::td] I get an empty set (namely, "No match").
for: //td[..] I get list of all the td elements.
I don’t understand what is the difference between the expressions, because that .. is shortcut of parent::.
>Solution :
Difference:
-
//td[parent::td]selects nothing because notdelements havetdparents. -
//td[..]selects alltdelements because alltdelements have a parent.
Both //td[parent::*] and //td[..] would select all td elements.