XPath: Nodes that have a child node that have an attribute
- by Jonathan Allen
XML Fragment
<component name='Stipulations'>
<group name='NoStipulations' required='N'>
<field name='StipulationType' required='N' />
<field name='StipulationValue' required='N' />
</group>
</component>
<component name='NestedParties3'>
<group name='NoNested3PartyIDs' required='N'>
<field name='Nested3PartyID' required='N' />
<field name='Nested3PartyIDSource' required='N' />
<field name='Nested3PartyRole' required='N' />
<group name='NoNested3PartySubIDs' required='N'>
<field name='Nested3PartySubID' required='N' />
<field name='Nested3PartySubIDType' required='N' />
</group>
</group>
</component>
<component name='UnderlyingStipulations'>
<group name='NoUnderlyingStips' required='N'>
<field name='UnderlyingStipType' required='N' />
<field name='UnderlyingStipValue' required='N' />
</group>
</component>
What I want is all "group" nodes which have a child node of type "field" and a name "StipulationType".
This is what I've tried so far:
dictionary.XPathSelectElements("group[field[@name='StipulationType']]")
dictionary.XPathSelectElements("group[./field[@name='StipulationType']]")