【发布时间】:2016-07-01 05:00:24
【问题描述】:
我需要根据前一个元素文本获取第二个元素的文本 (Description)。
<world>
<continent>europe</continent>
<description>germany, france, italy, spain</description>
</world>
<world>
<continent>asia</continent>
<description>japan, thailand, china</description>
</world>
<world>
<continent>africa</continent>
<description>south africa, simbabwe, tansania</description>
</world>
XPath:
//world[continent="africa"]/description
我尝试了几种变体,但没有一种效果很好。 有什么想法吗?
【问题讨论】:
-
什么价格要素?它在 XML 中的什么位置?
-
抱歉。在写作时改变故事。
-
您的 xml 没有根元素,它无效。添加后,
/world将一无所获。您需要再添加一个斜线才能使其正常工作//world[continent="africa"]/description。