Yes, this is correct. The variable "example" in your foreach loop will contain the value of the "if" attribute.
Up vote 0 down vote favorite share g+ share fb share tw.
I just have some codes here to clarify my doubts on linq xml parsing. I have the following: ... { XDocument xmlDoc = XDocument. Load(@"C:\Build.
Xml"); var abc = from example in xmlDoc. Descendants("target") select (string)target. Attribute("if"); ... foreach(string example in abc) { ... } ... } Can I ask that if it is true that in the line select (string)target.
Attribute("if") I am selecting a string from the xml file from the value of "if" as shown in the xml file below: then I have this line: foreach(string example in abc) Is it true that for every selected string of the "value" of the "if" attribute, I am doing something in the foreach loop. C# linq linq-to-xml link|improve this question edited Mar 9 '11 at 6:54BoltClock's a Unicorn?101k14145376 asked Mar 9 '11 at 6:49jeremychan37928 65% accept rate.
Step through the debugger and see what it tells you. – BoltClock's a Unicorn? Mar 9 '11 at 6:52 I added a break point and checked what abc is.
And this is what they say: {System.Linq.Enumerable. WhereSelectEnumerableIterator} base {System.Linq.Enumerable. Iterator}: {System.Linq.Enumerable.
WhereSelectEnumerableIterator} I am not sure if it is correct – jeremychan Mar 9 '11 at 6:59.
Yes, this is correct. The variable "example" in your foreach loop will contain the value of the "if" attribute. Var abc = from target in xDocument.
Descendants("target") select (string)target. Attribute("if"); foreach (var example in abc) { Console. WriteLine(example); } try the above code in a console application and you'll see the values in the console window.
Or you could use Debug. WriteLine(example) in a different type of application This is a better linq query expression however var abc = from target in xDocument. Descendants("target").
Attributes("if") select target. Value; or change your linq query expression to var abc = from target in xDocument. Descendants("target") select target.
Attribute("if"). Value; EDIT To help with your issue with the Debugger: I've moved my mouse over abc and I see the debugger pop up the information window as shown in the image below This first images show the "Results View" has those green arrows. You need to click on those arrows before you can see the result (as the message next to them says) The second image then shows you the results.
1 Nice debugger example + screenshots. – BoltClock's a Unicorn? Mar 9 '11 at 7:37 @jeremychan I've edited my answer to include some images that I think might help you with why you're not seeing the values in the variable abc (which is an IEumerable or some kind) – Shiv Kumar Mar 9 '11 at 7:37.
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.