Quering XElements for children with children attributes?

You're checking whether the XAttribute object is equal to the string e Since an XAttribute object is never equal to a string, it doesn't work You need to check the XAttribute object's Value like this: where y => y. Attribute("lang"). Value == "e.

You're checking whether the XAttribute object is equal to the string "e". Since an XAttribute object is never equal to a string, it doesn't work. You need to check the XAttribute object's Value, like this: where y => y.

Attribute("lang"). Value == "e.

1 for faster than me by 2 minutes, but you haven't mentioned the second point that I have (and Stephan too). – Mark Byers May 11 '10 at 19:58 Thanks. I knew that it was something small.

Always is. Which format is the best to use: Method based or query based? – Arnej65 May 11 '10 at 19:58 1 @Arnej65 Query based gets translated to methods by the compiler, so use which over method is easier for you to read.

– Stephan May 11 '10 at 20:10.

You are comparing the attribute object with the string "e", rather than the value of the attrbute object. You're also returning the value of the node rather than the node. Since the value is empty, you'll just get the empty string.

Try this instead: var EnglishSet = (from e in single. Elements("Child") where e. Attribute("lang").

Value == "e" select e).FirstOrDefault().

Var EnglishSet = (from e in single. Elements("Child") where e. Attribute("lang").Value.

Equals("e") select e).FirstOrDefault(); As Slaks stated you were checking that the attribute not it's value was "e". You also don't need select e. Value because the "Child" nodes don't have a value they have "record" children.

True true. I'm getting all the data in "record" and not the nodes. – Arnej65 May 11 '10 at 20:04.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions