Adding integer value to a list from XML file
Posted
by Pramodh
on Stack Overflow
See other posts from Stack Overflow
or by Pramodh
Published on 2010-06-11T05:52:54Z
Indexed on
2010/06/11
6:12 UTC
Read the original article
Hit count: 245
I've an Xml file like
<SampleFile>
<Data>
<Element Val="8" />
<Element Val="10" />
<Element Val="12" />
<Element Val="14" />
<Element Val="16" />
<Element Val="9" />
<Element Val="11" />
<Element Val="13" />
<Element Val="15" />
<Element Val="17" />
</Data>
</SampleFile>
i need to read the attribute value of" Val" and convert it to Int32 , then sort and then add to the list
now i'm using like:
List<Int32> lst = (XDocument.Load("\\Sample.xml").Descendants("Element").Select(l_Temp => l_Temp.Attribute("Val").Value.ToString()).Cast<Int32>().OrderBy(nTemp => nTemp)).ToList();
but its not working properly
please give me a better solution
© Stack Overflow or respective owner