Greetings!
If I have XML such as this:
<Root>
<AlphaSection>
.
.
.
</AlphaSection>
<BetaSection>
<Choices>
<SetA>
<Choice id="choice1">Choice One</Choice>
<Choice id="choice2">Choice Two</Choice>
</SetA>
<SetB>
<Choice id="choice3">Choice Three</Choice>
<Choice id="choice4">Choice Four</Choice>
</SetB>
</Choices>
</BetaSection>
<GammaSection>
.
.
.
</GammaSection>
</Root>
I'd like to get all of the Choice items in the "BetaSection", regardless of the "Set" that they belong to. I've tried the following:
var choiceList = from choices in myXDoc.Root.Element("BetaSection").Elements("Choices")
where (choices.Name == "Choice")
select new
{
Name = choices.Attribute("id").Value,
Data = choice.Value
};
But to no avail. How would I go about this?
Thanks.