简体   繁体   中英

XPath query to parse xml properties file

I have the following xml document:

<!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>

I am executing the following xpath query:

/properties/entry[@key='HappyKey']  

I anticipate this to return HappyKey, however it returns nothing.

如果仅在寻找值,请尝试:

/properties/entry[@key='HappyKey']/text()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM