gpt4 book ai didi

xpath 子 foo 出现在子 bar 之前的所有节点

转载 作者:行者123 更新时间:2023-12-03 17:17:34 25 4
gpt4 key购买 nike

<list>
<head>Fruit</head>
<type>Consumables</type>
<item>Apple</item>
<item>Banana</item>
<item>Coffee</item>
<list>
<list>
<head>Airports</head>
<label>SFO</label>
<item>San Francisco</item>
<label>LHR</label>
<item>London</item>
<list>

全部匹配 <list> <label> 所在的节点出现在第一个 <item> 之前.上面的第一个列表不匹配;第二个会。

我可以假设至少有一个 <item> .它可能是唯一的 child 。

(XPath/XSLT 1.0)

最佳答案

使用 :

 /*/list[*[self::label or self::item][1][self::label]]

这可能比使用反向轴更有效,因为评估在 list 的第一个找到的子节点处停止。即 labelitem .

关于xpath 子 foo 出现在子 bar 之前的所有节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11641289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com