2
如何檢查Xrclist
中是否存在XTclist
的值。檢查類型爲IEnumerable <XAtrribute>的列表中的值是否存在於同一類型的另一個列表中+ LINQ to XML
XR
:
<result>
<claims type="Subject">
<scope_of_claim>Full scope</scope_of_claim>
<claim_date>02/28/2009</claim_date>
<claim_age months="1" years="2" />
</claims>
<claims type="Vehicle">
<scope_of_claim>Full scope</scope_of_claim>
<claim_date>12/8/2010</claim_date>
<claim_age months="1" years="2" />
</claims>
XT
:
<result>
<claims type="Vehicle">
<scope_of_claim>Full scope</scope_of_claim>
<claim_date>24/1/2011</claim_date>
<claim_age months="2" years="0" />
</claims>
</result>
代碼:
var XRclist = XR.Descendants("claims").Attributes("type");
var xTclist = XT.Descendants("claims").Attributes("type");
foreach (var c in xTclist)
{
if (XRclist.Contains(c.value)) // This line need to be corrected
{
Do some thing.
}
else
{
Do something else.
}
}
謝謝。這樣可行。 – BumbleBee 2011-06-03 22:44:43