我有很多表,我想从这些表中选择所有节点,除了那些至少包含li节点的表。
示例:
<table>
<tr><td>all these nodes should match</td></tr>
</table>
<table>
<tr><td><ul><li>all these nodes including table should NOT match</li></ul></td></tr>
</table>
<table>
<tr><td><div>all these nodes should match</div></td></tr>
</table>
答案 0 :(得分:3)
/root/table[not(descendant::li)]
<?xml version="1.0" encoding="UTF-8"?>
<root>
<table>
<tr>
<td>all these nodes should match</td>
</tr>
</table>
<table>
<tr>
<td>
<ul>
<li>all these nodes including table should NOT match</li>
</ul>
</td>
</tr>
</table>
<table>
<tr>
<td>
<div>all these nodes should match</div>
</td>
</tr>
</table>
</root>
答案 1 :(得分:0)
试试这个
//table[count(.//li) eq 0]