I have a list which contains XML strings. How can I sort this list according to one of the XML attribute?



For example:


The list is defined as: List listOfXML = new List();


If this list contains 3 XML strings as given below, how can I sort this list according to "ThirdAttribute"?


XML string 1:



<Element>
<FirstAttribute>A</FirstAttribute>>
<SecondAttribute>B</SecondAttribute>
<ThirdAttribute>3</ThirdAttribute>
</Element>


XML string 2:



<Element>
<FirstAttribute>C</FirstAttribute>>
<SecondAttribute>D</SecondAttribute>
<ThirdAttribute>4</ThirdAttribute>
</Element>


XML string 3:



<Element>
<FirstAttribute>A</FirstAttribute>>
<SecondAttribute>B</SecondAttribute>
<ThirdAttribute>1</ThirdAttribute>
</Element>

No comments:

Post a Comment