gpt4 book ai didi

xml - 如何使用xpath从节点获取属性值?

转载 作者:数据小太阳 更新时间:2023-10-29 01:39:09 27 4
gpt4 key购买 nike

对 xpath 完全陌生。

我有 xml:

<Values>
<Value Value="a" CustomAtr="1" />
<Value Value="b" CustomAtr="2" />
<Value Value="c" CustomAtr="3" />
</Values>

要通过索引获取值,我可以使用:string(/*/Value[1]/@CustomAtr)

是否可以通过key取值?热获取 CustomAtr 值在哪里 Value="b" ?

谢谢

最佳答案

这应该可以解决问题:

string(//Value[@Value='b']/@CustomAttr)

关于xml - 如何使用xpath从节点获取属性值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13194183/

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