作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
目前我有一些像这样的 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/
我是一名优秀的程序员,十分优秀!