gpt4 book ai didi

xml - Xpath从兄弟节点的父节点获取值

转载 作者:数据小太阳 更新时间:2023-10-29 02:22:19 29 4
gpt4 key购买 nike

目前我有一些像这样的 xml 结构:

<element type="Input" name="nationality">
<property i18n="true" text="Nationality" prefix="person.nationality."
name="caption">caption</property>
<property i18n="true" text="Nationality" prefix="person.nationality."
name="desc">desc</property>
<property name="visible">1</property>
<property name="mandatory">0</property>
<property name="value">AUS</property>
<restriction prefix="country." base="String">
<enumeration text="Albania" value="ALB" />
<enumeration text="Algeria" value="DZA" />
<enumeration text="Argentina" value="ARG" />
<enumeration text="Australia" value="AUS" />
<enumeration text="Austria" value="AUT" />
<enumeration text="Bahrain" value="BHR" />
</restriction>
</element>

我想问一下有没有办法使用xpath来提取枚举[@text]标签的值,其值等于属性[@name='value']中的文本。在本例中,期望文本为“澳大利亚”。

这只是我第一次使用 xpath,任何想法将不胜感激。谢谢大家。

最佳答案

使用:

/*/*/enumeration[@value = ../../*[@name = 'value']]/@text

关于xml - Xpath从兄弟节点的父节点获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13338214/

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