0

我有很多表,我想从这些表中选择所有节点,除了那些至少包含一个 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>
4

2 回答 2

4

路径:

/root/table[not(descendant::li)]

XML:

<?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>
于 2012-05-28T06:12:17.817 回答
0

尝试这个

//table[count(.//li) eq 0]
于 2012-05-28T13:09:24.350 回答