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
SESSIONEXTENSION
element'sTYPE
attribute value equals"READER"
, - the child
ATTRIBUTE
element'sNAME
attribute value equals"General Options"
and - the child
ATTRIBUTE
element'sVALUE
attribute 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
)?
@VALUE=...
instead ofVALUE=...
– Peter B/SESSION[SESSIONEXTENSION[@TYPE='READER'] and ATTRIBUTE[@NAME="General Options" and @VALUE =""]]
– splash58