我有以下代码:
<include>
<fallback>
<title>Content</title>
</fallback>
</include>
<include>
<fallback>
<title>Content</title>
</fallback>
</include>
<include> <-- I want this.
<fallback>
<title>Content</title>
</fallback>
</include>
<adhoc>
<title>Content</title>
</adhoc>
<include>
<fallback>
<title>Content</title>
</fallback>
</include>
我需要找到第三个<include>
,因为它有<adhoc>
作为其直接跟随兄弟。有没有用XPath找到这个?
答案 0 :(得分:4)
&#34;我需要找到第三个
<include>
,因为它有<adhoc>
,因为它直接跟随兄弟。&#34;
此要求可以转换为XPath,如下所示:
//include[following-sibling::*[1][self::adhoc]]