0
我希望這是有道理的。我有以下XML文檔。C#,LINQ獲取指定父元素的子元素
<PrinterDirectory>
<Country Name="UK>
<Region Name="Aberdeen" />
<Region Name="Birmingham" />
<Region Name="London" />
</Country>
<Country Name="France">
<Region Name="Paris" />
<Region Name="Bordeaux" />
</Country>
</PrinterDirectory>
什麼是LINQ檢索英國只是地區例如?
我已經試過
varRegionQuery = from items in xdoc.Descendants("Country")
where items.Attribute("Name").Value == "UK"
select new
{
_Region = items.Element("Region").Attribute("Name").Value
};
這不過只檢索 「仔」。
工作過,感謝您的時間。 – 2010-11-04 15:59:44