"root"
is your aValues
element. So, there is no "root"
elements in children of aValue
, and aValues.Element("root")
gives you null
.
Correct query:
aValue.Elements()
.Select(e => new KeyValuePair<string, object>(e.Name.LocalName, e.Value))
.ToList();