I have an XML document for which I want to sort specific nodes alphabetically.
XML document
I tried the following code and it is working (C#) you can get values as below
var doc = new XmlDocument();
doc.Load("c:\\users\\ozgur\\sample.xml");
var nav = doc.CreateNavigator();
var node = nav.SelectSingleNode("response").SelectSingleNode("lst[@name=\"facet_counts\"]").SelectSingleNode("lst[@name=\"facet_fields\"]").SelectSingleNode("lst[@name=\"professions_raw_nl\"]").Select("int");
var sorted = new SortedDictionary();
while (node.MoveNext())
{
var name = node.Current.SelectSingleNode("@name").Value;
var value = node.Current.Value;
sorted.Add(name, value);
}
foreach (var item in sorted)
{
item.Key.ToString();
item.Value.ToString();
}