我有一個Xml文件,我想在XPath中進行過濾。我嘗試了很多例子,但沒有一個能夠幫助我毫無疑問地犯了一些錯誤。 我是XPath新手,請幫我找到解決方案。如何爲XML創建XPath?
<PeopleBatch Counter="3">
<Citriz ID="1d9a88fe-f9cc-4add-b6d1-01e41c561bfb" mVersion="1.0.0" mSequence="1" pVersion="0.0.1" xmlns="http://Citriz/Schemas">
<People Action="U" Status="CD" PeopleID="1" PeopleShortName="Billy" PeopleLongName="Billy Smith" PeopleTypeCode="Commercial" CountryCode="USA" PeopleStatus="Current">
<PeopleRole Action="U" Status="CD" ID="1" CustomerRoleShortName="Billy" CustomerRoleLongName="Billy Smith" TypeCode="OUTS">
<SendRole RoleType="N" ActiveRole="Y"/>
</PeopleRole>
</People>
</Citriz>
<Citriz ID="1d9a88fe-f9cc-4add-b6d1-01e41c561bfc" mVersion="1.0.0" mSequence="2" pVersion="0.0.1" xmlns="http://Citriz/Schemas">
<People Action="U" Status="CD" PeopleID="2" PeopleShortName="Carl" PeopleLongName="Carl Thomas" PeopleTypeCode="Commercial" CountryCode="USA" PeopleStatus="Current">
<PeopleRole Action="U" Status="CD" ID="2" CustomerRoleShortName="Carl" CustomerRoleLongName="Carl Thomas" TypeCode="INSS">
<SendRole RoleType="N" ActiveRole="Y"/>
</PeopleRole>
</People>
</Citriz>
<Citriz ID="1d9a88fe-f9cc-4add-b6d1-01e41c561bfd" mVersion="1.0.0" mSequence="3" pVersion="0.0.1" xmlns="http://Citriz/Schemas">
<People Action="U" Status="CD" PeopleID="3" PeopleShortName="Ryan" PeopleLongName="Ryan Black" PeopleTypeCode="Commercial" CountryCode="USA" PeopleStatus="Current">
<PeopleRole Action="U" Status="CD" ID="3" CustomerRoleShortName="Ryan" CustomerRoleLongName="Ryan Black" TypeCode="INSS">
<SendRole RoleType="N" ActiveRole="Y"/>
</PeopleRole>
</People>
</Citriz>
我需要哪些子節點屬性包含類型碼= 「INSS」 這個值的所有那些 「Citriz」 節點。或者建議我是否有其他好方法。
非常感謝答覆,但它不返回兩個節點。 – 2013-05-02 21:07:44
@PankajMishra我假設你想要第一個。只需用'Where'代替'First'。就這些。我更新了答案。 – I4V 2013-05-02 21:09:05