2011-01-06 9 views
0

RSSフィードを解析して表示しています。ASP Classicにある特定のノードで項目をアルファベット順に並べ替えたいと思います。Parsin - ASPの多次元配列またはオブジェクトリストのny値またはプロパティを並べ替える

私は2つだけを必要なときに辞書オブジェクトにタイトルとリンクを追加

が私のために働いていた。これを行うための最善の方法は何か、LNAME」ノードでitemListのをソートする必要がある

Set xmlDOM = Server.CreateObject("MSXML2.DOMDocument") 
xmlDOM.async = False 

xmlDOM.setProperty "ServerHTTPRequest", True 
xmlDOM.Load("http://myfeedhere.xml") 

Set itemList = xmlDOM.getElementsByTagName("item") 

''# Then I am getting the values of each node this way: 

For Each item in itemList 
    For Each child in item.childNodes 
     Select case lcase(child.nodeName) 
      case "title" 
       title = child.text 

      case "link" 
       link = child.text 

      case "fname" 
       fname = child.text 

      case "lname" 
       lname = child.text 

      case "media:content" 
       media = child.getAttribute("url") 
     End Select 
    next 

キーの配列にクイックソートを呼び出してそれに応じて出力します。さらに、姓が重複しないようにする必要があります。

+0

は、編集AnthonyWJonesいただきありがとうございます、 – Alex

答えて

0

助けを借りてありがとう、http://www.4guysfromrolla.com/webtech/012799-3.shtml 2次元クイックソート機能 私は解決策を見つけました(bes )

を.NETとC#にアップデートするクライアントを伝えるのIDE ...

dim xmlDOM,itemList,currentLetter 
Set xmlDOM = Server.CreateObject("MSXML2.DOMDocument") 
xmlDOM.async = False 

xmlDOM.setProperty "ServerHTTPRequest", True 
xmlDOM.Load("http://yourrssfeedhere.xml") 


    Set itemList = xmlDOM.getElementsByTagName("item") 

    dim itemListLength 
    itemListLength = itemList.length 

    dim lastIndex 
    lastIndex = itemListLength -1 
    'get the value of the last index of all the items 

    dim byLastName() 

    redim byLastName(lastIndex,3) 

    ' set two-dimensinal array indexes, ([lastIndexofItemlist],[#of fields]) 


    dim it 

    For Each item in itemList 
    itemCount = itemCount + 1 




    For Each child in item.childNodes 


    Select case lcase(child.nodeName) 

' loop through each node of item and set variable, set each case for your specific nodes in each <item> 
' (i.e <category>,<lname>,etc) 

    case "title" 
     title = child.text 

    case "description" 
     description = child.text 

    case "link" 
     link = child.text 

    case "pubdate" 
     pubdate = child.text 


    case "fname" 
     fname = child.text 

    case "lname" 
     lname = child.text 

     case "media:content" 
     media = child.getAttribute("url") 


    End Select 



    next 

    i = itemCount-1 



    byLastName(i,0) = title 
    byLastName(i,1) = link 
    byLastName(i,2) = lname 
    byLastName(i,3) = fname 


    next 



    dim namesLength 
    namesLength = Ubound(byLastName) 

'last index of bylastname 

for n = 0 to namesLength 
' simple output before sort 
Response.Write("<p> Last Name :" & byLastName(n,2) & ", First Name :" & byLastName(n,3) &"</p>") 
next 

Response.Write("<p> Sorted:</p>") 



Call QuickSort(byLastName,0,ubound(byLastName,1),2) 

'the last parameter is the field to sort the array on , 
' in this case 2 = lname 
    for n = 0 to namesLength 
    ' output to test sort 
    Response.Write("<p> Last Name :" & byLastName(n,2) & ", First Name :" & byLastName(n,3) &"</p>") 

    next 
関連する問題