我有我想要的特定節點按字母順序排序的XML文檔。排序XML節點上的字母屬性名稱
XML文檔
<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>
希望的輸出
牙醫(1309)
博士(2246)
藥劑(2724)
理療(2474)
電流ASP .NET代碼
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
您使用的任何版本或.Net> = 3.5? –
傑普,使用ASP.NET 4.0 – Flo
看到我答..這將對於.NET> = 3.5 –