XPath: Nodes that have a child node that have an attribute

Posted by Jonathan Allen on Stack Overflow See other posts from Stack Overflow or by Jonathan Allen
Published on 2010-05-18T01:05:58Z Indexed on 2010/05/18 1:10 UTC
Read the original article Hit count: 262

Filed under:
|

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']]")

© Stack Overflow or respective owner

Related posts about .NET

Related posts about xpath