我有以下xml文档:
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>My Happy Configuration</comment>
<entry key="HappyKey">Happy Key</entry>
<entry key="SadKey">Sad Key</entry>
<entry key="AngryKey">Angry Key</entry>
<entry key="ConfusedKey">Confused Key</entry>
...
</properties>
我正在执行以下xpath查询:
/properties/entry[@key='HappyKey']
我预计这将返回HappyKey,但它不返回任何内容。
答案 0 :(得分:2)
如果您只想查找该值,请尝试:
/properties/entry[@key='HappyKey']/text()