Retrieve all child elements' values (Linq Query)?

Var controls = from str in xdoc. Elements("string") where str. Attribute("id").

Value == tagBox. Text from cont in str. Elements("control") from type in cont.

Elements("type") select type Or, even simpler: var controls = from str in xdoc. Elements("string") where str. Attribute("id").

Value == tagBox. Text from type in str. Elements("control").

Elements("type") select type.

Var controls = from str in xdoc. Elements("string") where str. Attribute("id").

Value == tagBox. Text from cont in str. Elements("control") from type in cont.

Elements("type") select type; Or, even simpler: var controls = from str in xdoc. Elements("string") where str. Attribute("id").

Value == tagBox. Text from type in str. Elements("control").

Elements("type") select type.

Thanks for the reply. Is the suggested query supposed to retrieve the values? I think it is, but am not sure, because when I run the program, that foreach up in my question is also supposed to print to the console each value inside of the var controls before it attempts to check any box in the checkbox control.

– Sean Glover Aug 5 at 15:49 1 This query returns all the elements (but you might want to select type. Value rather than just type) – Thomas Levesque Aug 5 at 15:55 Hmm, still have issues it seems. It looks like controls comes back empty.

– Sean Glover Aug 5 at 16:02 Got it working. The key was that I had to change xdoc. Elements("string") to xdoc.

Descendants("string"). Thanks again Thomas! – Sean Glover Aug 5 at 16:06 1 @Sean, actually you should do xdoc.Root.

Elements("string"). Elements is faster than Descendants, because it doesn't search recursively. It's better to use Elements when you know the exact structure of the document – Thomas Levesque Aug 5 at 16:58.

In that task retrieve the values of the Name, Location and Arguments tags. Then open the RunWhen tag and retrieve the values of the Time and Date tags. After that open the Days tag and retrieve the value of each individual tag within.

Retrieve the value of Enabled. Load the next task and repeat steps 3 -> 7 until all the Task tags in Tasks have been parsed. I'm very sure you can do it this way I just can't work it out as there are so many different ways to do things in XML I got a bit overwhelmed.

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