Grettings!
I have some XML that looks like this:
<Root> <SectionA> <Item id='111'> <Options> <Option val='a' cat='zzz'> <Package value='apple' /> <Feature value='avacado' /> </Option> <Option val='b' cat='yyy'> <Package value='banana' /> <Feature value='blueberry' /> </Option> </Options> </Item> <Item id='222'> <Options> <Option val='c' cat='xxx'> <Package value='carrot' /> <Feature value='cucumber' /> </Option> <Option val='d' cat='www'> <Package value='dairy' /> <Feature value='durom' /> </Option> </Options> </Item> </SectionA> <SectionB> . . . </SectionB> </Root>
I’d like to get the PACKAGE and FEATURE values based on the ID attribute of ITEM being ‘111’ and the VAL attribute of OPTION being ‘a’.
I’m not sure where to start. I’m able to select the ITEM node using a where, but I’m not sure how to combine that with a where clause on the OPTION node. Any ideas?
This works for me.
You can omit the
letparts if you want, they are only to make the anonymous type thinner.Actually, I kind of like the second one more.
And the non query Linq style.