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::
.
CodePudding user response:
Difference:
//td[parent::td]
selects nothing because notd
elements havetd
parents.//td[..]
selects alltd
elements because alltd
elements have a parent.
Both //td[parent::*]
and //td[..]
would select all td
elements.