gpt4 book ai didi

xml - 如何根据 child 选择元素

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

我不是PowerShell或XPath的专家,但是我在如何解决这个看似简单的问题上有些挣扎。说我有这个XML文档:

<?xml version="1.0" encoding="utf-8"?>
<Cars>
<Car>
<Name>Car1</Name>
<Colors>
<Color>
<Name>Indian yellow</Name>
<Effects>
<Effect>Blur</Effect>
<Effect>Shadow</Effect>
</Effects>
</Color>
<Color>
<Name>Fireapple red</Name>
<Effects>
<Effect>Shadow</Effect>
</Effects>
</Color>
</Colors>
</Car>
<Car>
<Name>Car2</Name>
<Colors>
<Color>
<Name>Indian yellow</Name>
<Effects>
<Effect>Blur</Effect>
<Effect>Shadow</Effect>
<Effect>Saturated</Effect>
</Effects>
</Color>
<Color>
<Name>Chrome black</Name>
<Effects>
<Effect>Saturated</Effect>
</Effects>
</Color>
</Colors>
</Car>
<Car>
<Name>Car3</Name>
<Colors>
<Color>
<Name>Indian yellow</Name>
<Effects>
<Effect>Shadow</Effect>
<Effect>Saturated</Effect>
</Effects>
</Color>
<Color>
<Name>Fireapple red</Name>
<Effects>
<Effect>Saturated</Effect>
</Effects>
</Color>
</Colors>
</Car>
</Cars>

如何使用Select-Xml选择具有颜色效果“饱和”的汽车的名称?请注意,我需要独特的汽车收藏,例如即使两种颜色都具有“饱和”效果,也不能两次选择Car2。

最佳答案

XPath /Cars/Car[Colors/Color/Effects/Effect = 'Saturated']/Name应该可以。

关于xml - 如何根据 child 选择元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14360367/

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