I have the following XML that is generated by a third-party library:
<PhoneNumbers> <PhoneNumber Key="1">123-456-7890</PhoneNumber> <PhoneNumber Key="2">234-567-8901</PhoneNumber> <PhoneNumber Key="3">345-678-9012</PhoneNumber> </PhoneNumbers>
The problem is that I should not depend on the values ββof the Key attribute (a) displayed in order, or (b) starting with 1. Moreover, the latter, but I want this processing to be as safe as possible.
What I need to do is get a list of phone numbers sorted by Key value (ascending). Therefore, using XmlNode.SelectNodes I would like the resulting XmlNodeList contain the PhoneNumber nodes in the correct order, and not in the order in which they appear.
How can this be done with XPath?
Is it possible to do this directly?
If that matters, I am using .NET 2.0.
sorting c # xpath order
Jon seigel
source share