Woot4Moo
Woot4Moo

Reputation: 24336

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.

Upvotes: 0

Views: 1454

Answers (1)

user416472
user416472

Reputation: 104

If you are looking for the value only then try:

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

Upvotes: 2

Related Questions