XML片段的XPath:有有一個屬性
<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>
我想是有類型的子節點「場」和一個名爲「StipulationType」所有「組」節點的子節點的節點。
這是我到目前爲止已經試過:
dictionary.XPathSelectElements("group[field[@name='StipulationType']]")
dictionary.XPathSelectElements("group[./field[@name='StipulationType']]")
好問題(+1)。查看我的答案,通常比使用'//'更有效。 :) – 2010-05-18 01:30:55