Reputation: 1306
I have node values where SData Event is different between the 2 elements below and need to return the Event value "WK1" when only providing the FormData "PEMD" and ItemData "2019-12-18" I can't provide the Subject value as this will not be known, only ItemData Value.
<Data>
<Data1 Study="R1979" MetaDataVersionOID="6713">
<Data2 Subject="4100">
<SData Event="SCN" key="WK1[1]">
<FormData Form="PEMD" FormKey="1">
<ItemData Item="PM" Value="1"/>
<ItemData Item="PE" Value="1"/>
<ItemData Item="DATE" Value="2020-01-01"/>
</FormData>
</SData>
</Data2>
</Data1>
<Data1 Study="R1979" MetaDataVersionOID="6713">
<Data2 Subject="4200">
<SData Event="WK1" key="WK1[1]">
<FormData Form="PEMD" Formkey="1">
<ItemData Item="PM" Value="1"/>
<ItemData Item="PE" Value="1"/>
<ItemData Item="DATE" Value="2019-12-18"/>
</FormData>
</SData>
</Data2>
</Data1>
I have tried
/Data/Data1/Data2/SData[@Event]/FormData[@Form='PEMD']
Upvotes: 1
Views: 67
Reputation: 5905
Alternative :
//FormData[@Form="PEMD"][./ItemData[@Value="2019-12-18"]]/../@Event
Look for a FormData
element with specific attribute (attribute : PEMD
) and a specific ItemData
child (attribute : 2019-12-18
). Then get the attribute (@Event
) of the parent element (..
).
Output : WK1
Upvotes: 1
Reputation: 111541
This XPath,
//SData[FormData[@Form="PEMD"]/ItemData[@Item="DATE"]/@Value="2019-12-18"]/@Event
will return the Event="WK1"
attribute as requested.
Upvotes: 1