K
K Viltersten
I'm running the following code.
XElement r = XElement.Load("info.xml");
IEnumerable<XElement>
des = r.Descendants("A").Descendants("A1");
foreach (XElement d in des)
string v = d.Descendants("A1a")
.First<XElement>().Value;
I was expecting LINQ to give me more easy
access to the data structure. Perhaps
someone can suggest some changes.
1. Can i shorten the assignment to des
somehow? Something like "A.A1" would be
very helpful.
2. Why do i need to specify the type to
First() using <XElement>? Isn't it always
a XElement? How can i retrieve an int or
double instead of string?
3. Frankly, i was expecting LINQ to give
me a structure where intellisense would
let me "dot my way through" to the data
i need. Is that doable?
Also, after some reading, i'm still
unclear about the relation between
XElement and XNode (and the other X's as
well, but that's the two that _sound_
like a related leaf-node pair).
K Viltersten
XElement r = XElement.Load("info.xml");
IEnumerable<XElement>
des = r.Descendants("A").Descendants("A1");
foreach (XElement d in des)
string v = d.Descendants("A1a")
.First<XElement>().Value;
I was expecting LINQ to give me more easy
access to the data structure. Perhaps
someone can suggest some changes.
1. Can i shorten the assignment to des
somehow? Something like "A.A1" would be
very helpful.
2. Why do i need to specify the type to
First() using <XElement>? Isn't it always
a XElement? How can i retrieve an int or
double instead of string?
3. Frankly, i was expecting LINQ to give
me a structure where intellisense would
let me "dot my way through" to the data
i need. Is that doable?
Also, after some reading, i'm still
unclear about the relation between
XElement and XNode (and the other X's as
well, but that's the two that _sound_
like a related leaf-node pair).
K Viltersten