Here's the sample XML
<?xml version="1.0" encoding="utf-8" ?>
<Instructions>
<Instruction>
<Brand>Brand1</Brand>
<Text>
this is text for Brand1
</Text>
</Instruction>
<Instruction>
<Brand>Brand2</Brand>
<Text>
Brand2 text is slightly different
</Text>
</Instruction>
<Instruction>
<Brand>Brand3</Brand>
<Text>
Brand3 has boring text
</Text>
</Instruction>
<Instruction>
<Brand>Brand4</Brand>
<Text>
Brand4 had long text until the editor got hold of this file
</Text>
</Instruction>
</Instructions>
My code is this:
string WhoAmI = "Brand1";
string t =
(from Instruction in xmlDoc.Descendants("Instruction")
where (string)Instruction.Element("Brand").Value == WhoAmI
select t = Instruction.Element("Text").Value
).ToString();
//end code
t is always
System.Linq.Enumerable+WhereSelectEnumerableIterator`2 [System.Xml.Linq.XElement,System.String]
not
this is text for Brand1
What am I doing wrong?