gpt4 book ai didi

JavaScript 和 Xpath

转载 作者:行者123 更新时间:2023-11-30 10:51:05 24 4
gpt4 key购买 nike

我使用的是普通的老式 Javascript - 所以请不要使用 jQuery 响应!

我已经加载了一个看起来像这样的 xml 文档

<node>
<child tags='Foo,Bar'>
------ GrandChild Nodes Here
</child>
<child tags='Nuts,Bolts'>
------ GrandChild Nodes Here
</child>
<child tags='Bacon,Eggs'>
------ GrandChild Nodes Here
</child>
</node>

我需要知道的是,如果我想获取已在 Foo 中标记的节点的所有子节点,例如我如何使用 xPath 执行此操作。

干杯

史蒂夫

最佳答案

使用这个 XPath 1.0 表达式:

/node/child[
contains(
concat(',',@tags,','),
',Foo,'
)
]/node()

关于JavaScript 和 Xpath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5305574/

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