Reading an XML Element using LINQ

Synth

New Member
I am trying to read a value from an XML file using LINQ.This is really the first time that I am trying to use LINQ vs. the ordinary C#/.Net approach.My XML looks like this:\[code\]<Description><Account Green="A" White="D">House</Account><Account Green="B" White="D">Car</Account></Description>\[/code\]This is the LINQexpression I am using. I'd like to read the value House, in other words, the element with the attribute A and D.\[code\]var feeds = (from item in doc.Descendants("Description") from category in item.Elements("Account") let attribute = category.Attribute("Green") let xAttribute = category.Attribute("White") where attribute != null && (xAttribute != null && (xAttribute.Value =http://stackoverflow.com/questions/10357896/="A" && attribute.Value =http://stackoverflow.com/questions/10357896/="D")) select item.Value).ToString(); \[/code\]I can't figure out what I am doing wrong.Any help is appreciated.
 
Back
Top