XPath - 如何比较字符串和序列?
XPath - How to compare string and sequence?
XML 简而言之:
...
<team>
<capitan>Zdeno Chara</capitan>
<alernativeCapitan>
<player>Zdeno Chara</player> <!-- NO Chara, he's the capitan obviously -->
<player>Someone Else</player>
<player>Someone Other</player>
</alernativeCapitan>
</team>
<team>
<capitan>Abc Edf</capitan>
<alernativeCapitan>
<player>Abc Xyz</player>
<player>Bac Edf</player>
<player>Abc 123</player>
</alernativeCapitan>
</team>
...
问:如何在 XPath 中比较一个字符串 (capitan) 与序列 (alternativeCapitan)?
我想知道capitain是不是也写成另类的capitan / player。仅在一个团队中进行比较。 (如果是这样,那就错了。仅此而已,结果是布尔值还是数字都没有关系。)
谢谢。
这个问题对我来说不是 100% 清楚,也许你想要这样的东西:
//team[capitan=alernativeCapitan/player]
上面的 XPath 将 return 所有 team
其中 capitan
也列在 alternativeCapitan
元素中。或者如果你想要相反的,那就是 return all team
where the capitan
is not in the alternativeCapitan
:
//team[not(capitan=alernativeCapitan/player)]
XML 简而言之:
...
<team>
<capitan>Zdeno Chara</capitan>
<alernativeCapitan>
<player>Zdeno Chara</player> <!-- NO Chara, he's the capitan obviously -->
<player>Someone Else</player>
<player>Someone Other</player>
</alernativeCapitan>
</team>
<team>
<capitan>Abc Edf</capitan>
<alernativeCapitan>
<player>Abc Xyz</player>
<player>Bac Edf</player>
<player>Abc 123</player>
</alernativeCapitan>
</team>
...
问:如何在 XPath 中比较一个字符串 (capitan) 与序列 (alternativeCapitan)?
我想知道capitain是不是也写成另类的capitan / player。仅在一个团队中进行比较。 (如果是这样,那就错了。仅此而已,结果是布尔值还是数字都没有关系。)
谢谢。
这个问题对我来说不是 100% 清楚,也许你想要这样的东西:
//team[capitan=alernativeCapitan/player]
上面的 XPath 将 return 所有 team
其中 capitan
也列在 alternativeCapitan
元素中。或者如果你想要相反的,那就是 return all team
where the capitan
is not in the alternativeCapitan
:
//team[not(capitan=alernativeCapitan/player)]