I've an xml file like
<Data>
<Element ValOne="1" Key="KeyOne" />
<Element ValOne="2" Key="KeyOne" />
<Element ValOne="3" Key="KeyOne" />
<Element ValOne="4" Key="KeyOne" />
<Element ValOne="5" Key="KeyTwo" />
<Element ValOne="6" Key="KeyTwo" />
<Element ValOne="7" Key="KeyThree" />
<Element ValOne="8" Key="KeyThree" />
<Element ValOne="9" Key="KeyThree" />
<Element ValOne="10" Key="KeyThree" />
</Data>
and a dictonary
Dictionary<string, List<string>> m_dictSample = new Dictionary<string, List<string>>();
i need to add the data from the file to dictonary like:
KeyOne "1"
"2"
"3"
"4"
KeyTwo "5"
"6"
KeyThree "7"
"8"
"9"
"10"
now i'm using like
List<string> lst = new List<string>();
lst = (XDocument.Load(Application.StartupPath + "\\Sample.xml").Descendants("Element").
Select(l_Temp => l_Temp.Attribute("Key").Value)).ToList();
m_dictSample = (from str in lst
from el in XDOC.Descendants("Element")
where (str == el.Attribute("Key").Value)
select new { Key = str, value =new List<string>( el.Attribute("ValOne") }).
ToDictionary(l_Temp => l_Temp.Key, l_Temp => l_Temp.value);
but its throwing an exception like " The best overloaded method match for 'System.Collections.Generic.List.List(int)' has some invalid arguments
please give me a better solution
Thanks in advance