I am trying to query an XML file. Below query
returns the first element in the sequence. Wondering how to get all elements in the sequence as a List.
rsltQuest is of type List of XElement.
rsltQuest = doc1.Descendants(xmlns + "QUESTION")
.Where(t => t.Attribute("ANSWER").Value == "no").ToList();`
Thanks for your advices.
M
I see two issues but both should not cause the result to be a one element list (provided there are more than one QUESTION elements having an ANSWER attribute with value “no”):
So, are you sure the data contains more than one QUESTION with ANSWER=”no”?
Or maybe this is a namespace issue?
EDIT: Maybe you should try
(string)(t.Attribute("ANSWER")) == "no"