我有以下xml文档。我正在尝试选择任何具有相同value2的兄弟姐妹且其中value3未关闭的孩子。
<root>
<child>
<value1>Type A</value1>
<value2>Class 1</value2>
<value3>Active</value3>
</child>
<child>
<value1>Type B</value1>
<value2>Class 1</value2>
<value3>Closed</value3>
</child>
<child>
<value1>Type C</value1>
<value2>Class 2</value2>
<value3>Active</value3>
</child>
<child>
<value1>Type D</value1>
<value2>Class 2</value2>
<value3>Active</value3>
</child>
<child>
<value1>Type E</value1>
<value2>Class 3</value2>
<value3>Active</value3>
</child>
</root>
我的尝试是:
// child [following-sibling :: child / value2 = value2 and value3!='Closed']
但是这没有将多个条件应用于下一个兄弟函数的预期结果。
有什么想法吗?
答案 0 :(得分:6)
//child[value2 = following-sibling::child[not(value3 = 'Closed')]/value2]
要申请任何兄弟姐妹,请联合following-sibling
和preceding-sibling
轴。
//child[value2 = (following-sibling::child | preceding-sibling::child)[not(value3 = 'Closed')]/value2]