这个xpath是什么意思? [英] what does this xpath mean?
问题描述
//p[not(ancestor::*[3])]
//table[ancestor::*[1][self::p] or ancestor::*[2][self::p]]
tr/td//a[ancestor::*[1`][self::td] or ancestor::*[2][self::td]]
推荐答案
// # from the root node, look at all descendants
p[ # select nodes of type <p>, who have…
not(ancestor::*[3]) # …no ancestor 3 levels up
] #
// # from these nodes, select descendants
table[ # of type <table>, who have…
ancestor::*[1][self::p] # …a <p> as their direct ancestor
or # or
ancestor::*[2][self::p] # …a <p> as their second ancestor
] #
# syntax error, this should be a location step
tr # …select all nodes of type <tr>
/ # from their children…
td # …select all nodes of type <td>
// # from their descendants…
a[ # …select all nodes of type <a>, who have
ancestor::*[1][self::td] # …a <td> as their direct ancestor
or # or
ancestor::*[2][self::td] # …a <td> as their second ancestor
]
或者,用 HTML 表示:
Or, expressed in HTML:
<html>
<body>
<p>
<table>
<tr>
<td>
<a title="These would be selected." />
</td>
</tr>
</table>
</p>
</body>
</html>
无论如何,整个 XPath 没有太大意义.不用说, The whole XPath does not make too much sense anyway. It goes without saying that 这篇关于这个xpath是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! 是无效的 HTML.
<p><table>
is invalid HTML.
登录
关闭