xml - how to get the text between two nodes using XPath -


i not know how values when nodes have same text.

here xml data.

<dict>     <key>value1</key>     <dict>         <key>us</key>         <string>zubehör</string>         <key>fr</key>         <string>accessories</string>     </dict>      <key>value2</key>     <dict>         <key>us</key>         <string>test2</string>         <key>fr</key>         <string>test</string>     </dict> </dict> 

how value value1 searching text accessories? real list larger. text given accessories. , need find parent's sibling text --> value1

this 1 possible way, given such description , tiny sample xml :

//dict[dict/string = 'accessories']/key 

we can't sure enough though, work correctly actual xml since sample xml posted contains only target element.

update :

to respond updated xml sample, can try way :

//dict/dict[string = 'accessories']/preceding-sibling::key[1] 

the xpath locates dict element containing keyword string, , return first preceding sibling key element.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -