XML
<?xml version="1.0" encoding="utf-8"?>
<DeviceIdMappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Devices>
<DeviceEntry>
<Key>907579560</Key>
<Value>SEMROUTER</Value>
</DeviceEntry>
</Devices>
</DeviceIdMappings>
CODE
string filename = @"C:\Users\Desktop\DeviceMapping.xml";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.PreserveWhitespace = true;
xmlDoc.Load(filename);
var xml = XElement.Load(filename);
Dictionary<uint, string> MasterDeviceMappings = (from x in xml.Descendants("DeviceEntry")
select new
{
Key = x.Element("Key").Value,
Value = x.Element("Value").Value,
}
).ToDictionary(q => uint.Parse(q.Key), q => q.Value);
Exexption
System.FormatException: 'Input string was not in a correct format.'
No idea whats wrong here. uint.Parse("907579560") works.