Given an XML document like:
<SESSION NAME ="TEST" REUSABLE ="NO" SORTORDER ="Binary" VERSIONNUMBER ="1">
<SESSIONEXTENSION DSQINSTNAME ="TEST_SQ" DSQINSTTYPE ="Source Qualifier" NAME ="Relational Reader" SINSTANCENAME ="TEST_SQ" SUBTYPE ="Relational Reader" TRANSFORMATIONTYPE ="Source Definition" TYPE ="READER"/>
<SESSIONEXTENSION DSQINSTNAME ="TEST_TG" DSQINSTTYPE ="Source Qualifier" NAME ="Relational Reader" SINSTANCENAME ="TEST_TG" SUBTYPE ="Relational Reader" TRANSFORMATIONTYPE ="Source Definition" TYPE ="WRITER"/>
<ATTRIBUTE NAME ="General Options" VALUE =""/>
</SESSION>
I wish to extract the NAME attribute of the SESSION element for SESSION elements for which all of the following are true:
- the child
SESSIONEXTENSIONelement'sTYPEattribute value equals"READER", - the child
ATTRIBUTEelement'sNAMEattribute value equals"General Options"and - the child
ATTRIBUTEelement'sVALUEattribute value equals"".
The XPath expression
/SESSION/SESSIONEXTENSION[@TYPE='READER']
returns a SESSION element containing the sought NAME attribute value.
However my attempt at an XPath expression specifying all three of the above list of SESSION element requirements
/SESSION/SESSIONEXTENSION[@TYPE='READER']/ATTRIBUTE[@NAME="General Options" and VALUE =""]
is not working as expected.
How can I state multiple conditions in an XPath expression where the conditions are for separate children (SESSIONEXTENSION, ATTRIBUTE) of a parent element (SESSION)?