gpt4 book ai didi

xpath - 如何使用 XPath 引用 XML 属性?

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

我的 XML:

<root>
<cars>
<makes>
<honda year="1995">
<model />
<!-- ... -->
</honda>
<honda year="2000">
<!-- ... -->
</honda>
</makes>
</cars>
</root>

我需要一个 XPath 来获取 <honda> 的所有模型与 1995 年。

所以:

/root/汽车/品牌/本田

但是如何引用一个属性呢?

最佳答案

"I need a XPath that will get me all models for <honda> with year 1995."



那将是:

/root/cars/makes/honda[@year = '1995']/model

关于xpath - 如何使用 XPath 引用 XML 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1529038/

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