I want to find the Xelement attribute.value which children have a concrete 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);
How can I get the attribute.value? What does it say that is a bool?
EDITED
Originally I Have the following XML:
<Assembly name="1">
<Assembly name="44" />
<Assembly name="3">
<Component name="2" />
</Assembly>
</Assembly>
I need to get the attribute.value where its children (XElement) has an expecific attribute.value
In this example, I would get the string “3” because i am searching the parent of the child which attribute.value == “2”
Because of how the nested
Whereclauses are written.The inner clause reads
This expression has a result of type
IEnumerable<XElement>, so the outer clause readsHowever
Whereexpects an argument of typeFunc<XElement, bool>and here you end up passing in aFunc<XElement, IEnumerable<XElement>>— hence the error.I ‘m not offering a corrected version because your intent is not clear at all from the given code, please update the question accordingly.
Update:
Looks like you want something like this: