I need to read an XML file to a dictionary.
I read few guides and I only got confused from weird words that I don\'t understand (such as nodes, XML validation etc.). So,
var data = XElement.Parse(xml)
.Elements("def")
.ToDictionary(
el => (int)el.Attribute("number"),
el => (string)el.Attribute("name")
);
This:
XElement
(starting at
)
elements@number
as the key (interpreting as an int
), and @name
as the value (as a string)data
, which is implicitly typed as Dictionary