Sortieren Sie XML-Knoten alphabetisch nach Attributnamen
Ich habe ein XML-Dokument, für das ich bestimmte Knoten alphabetisch sortieren möchte.
XML-Dokument
<response>
<lst name="facet_counts">
<lst name="facet_fields">
<lst name="professions_raw_nl">
<int name="Pharmacy">2724</int>
<int name="Physiotherapy">2474</int>
<int name="Doctor">2246</int>
<int name="Dentist">1309</int>
</lst>
</lst>
</lst>
</response>
Gewünschte Ausgabe
Zahnarzt (1309)
Arzt (2246)
Apotheke (2724)
Physiotherapie (2474)
Aktueller ASP.NET-Code
dim node as XmlNode = objXML.SelectSingleNode("response/lst[@name=""facet_counts""]/lst[@name=""facet_fields""]/lst[@name=""professions_raw_nl""]")
Dim sbuilder As New StringBuilder
Dim navigator As XPathNavigator = node.CreateNavigator()
Dim selectExpression As XPathExpression = navigator.Compile("???") <-- what expression should I use here ???
selectExpression.AddSort("????", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Text) <-- what expression should I use here ????
Dim nodeIterator As XPathNodeIterator = navigator.Select(selectExpression)
While nodeIterator.MoveNext()
'how can I print the name and value of the node?
End While