【发布时间】:2012-06-14 12:07:02
【问题描述】:
我想找到Xelement的attribute.value,哪个孩子有一个具体的attribute.value。
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?它说什么是布尔值?
已编辑 最初我有以下 XML:
<Assembly name="1">
<Assembly name="44" />
<Assembly name="3">
<Component name="2" />
</Assembly>
</Assembly>
我需要获取其子 (XElement) 具有特定属性的属性值。 在这个例子中,我会得到字符串“3”,因为我正在搜索子元素的父元素 which attribute.value == "2"
【问题讨论】:
标签: c# .net linq compiler-errors linq-to-xml