I doubt there is a way to get the element which has a particular value (text) from xml document using xpath.
Example doc:
<domain log-root="/logs" application-root="/applications"><resources>
<jdbc-resource pool-name="SamplePool" jndi-name="jdbc/sample" />
<jdbc-resource pool-name="TimerPool" jndi-name="abc">text1</jdbc-resource>
<jdbc-resource pool-name="TimerPool" jndi-name="def">text2</jdbc-resource>
<jdbc-resource pool-name="TimerPool" jndi-name="ghi">text3</jdbc-resource></resources</domain>
Example xPath Query:
/domain//jdbc-resource[@pool-name='TimerPool']/text()='text2'
Please post your ideas if there is any.
Use:
or you may use:
Both expressions above select all
jdbc-resourceelements the string value of whosepool-nameattribute is"TimerPoool"and whose string value (of thejdbc-resourceelement) is"text2"and that are grand-children of the top element of the XML document.