I have got a xml file which looks like this:
<events>
<event id="12345">
<option href="1"></option>
<option href="2"></option>
<option href="3"></option>
<option href="4"></option>
</event>
</events>
I am trying to select a pair of information from these nodes: the event id (12345) and the attribute of the elements option
var nodeWithOptions = from n in xml.Descendants("event")
select new
{
id = n.Attribute("id").Value,
options = n.Elements("option").Attributes("href").ToString(),
};
unfortunately this produces the following for options inside my foreach-loop: item.options = "System.Xml.Linq.Extensions+d__8"
What I want is: 12345, 1234 (yes I do not mind if the attribute value of the 4 option elements are in one string. And I also cannot change the xml file and I would prefer to use only linq.