我想找到Xelement attribute.value,其中的子項具有一個具體的attribute.value。無法將類型'IEnumerable <XElement>'隱式轉換爲'bool'
string fatherName = xmlNX.Descendants("Assembly")
.Where(child => child.Descendants("Component")
.Where(name => name.Attribute("name").Value==item))
.Select(el => (string)el.Attribute("name").Value);
如何獲取attribute.value?它說什麼是一個布爾?
EDITED 本來我有下面的XML:
<Assembly name="1">
<Assembly name="44" />
<Assembly name="3">
<Component name="2" />
</Assembly>
</Assembly>
我需要在那裏它的孩子(的XElement)具有attribute.value 的expecific在這個例子中attribute.value,我會得到字符串「3」,因爲我正在搜索子的父屬性attribute.value ==「2」
,我剪輯我的問題。謝謝 – kmxillo
@kmxillo:更新了答案。 – Jon