How to sort xml data using classic asp(vbscript) with out xpath?

Go To StackoverFlow.com

2

    <rooms>     
        <room>
            <roomname>Single</roomname>
            <roomid>1</roomid>
            <Price>100</Price>
            <Adult>1</Adult>
            <child>0</child>
        </room> 
    </rooms>


    <rooms>
        <room>
            <roomname>Double</roomname>
            <roomid>2</roomid>
            <Price>200</Price>
            <Adult>2</Adult>
            <child>1</child>
        </room>
    </rooms>

    <rooms>
        <room>
            <roomname>Single</roomname>
            <roomid>3</roomid>
            <Price>150</Price>
            <Adult>1</Adult>
            <child>0</child>
        </room>
    </rooms>

</hotel>

i need out put like this ...( use vbscript in classic asp )

Hotel :
Single-100, Double-200, Total 300

Single-150, Double-200, Total 350

concept is: 1. customer need 2 rooms, 1st room 1 adult and 2nd room 2adults + 1child ( based on above xml) 2. customer he can choose up to max 4 rooms, each rooms max adult is 4 and max child is 2, for that each customer request xml is generated like this

for example: customer need 3 rooms, 1st room 1 adult, 2nd room 2 adult +1child and 3rd room 3adult , xml is like this (rooms is generated based on the availability)...

    <rooms>     
        <room>
            <roomname>Single</roomname>
            <roomid>1</roomid>
            <Price>100</Price>
            <Adult>1</Adult>
            <child>0</child>
        </room> 
    </rooms>


    <rooms>
        <room>
            <roomname>Double</roomname>
            <roomid>2</roomid>
            <Price>200</Price>
            <Adult>2</Adult>
            <child>1</child>
        </room>
    </rooms>

    <rooms>
        <room>
            <roomname>Single</roomname>
            <roomid>3</roomid>
            <Price>150</Price>
            <Adult>1</Adult>
            <child>0</child>
        </room>
    </rooms>

               <rooms>      
        <room>
            <roomname>Triple</roomname>
            <roomid>4</roomid>
            <Price>300</Price>
            <Adult>3</Adult>
            <child>0</child>
        </room> 
    </rooms>

</hotel>

in this cause out put i need like this

Hotel :
Single-100, Double-200, Triple-300, Total 600

Single-150, Double-200, Triple-300, Total 650

I try to take out using vbscript, but some cause is accepted but some cause not

<%@ Language="VBScript" CodePage="65001"%>  
<%   
Response.ContentType = "text/plain; charset=UTF-8"  
Dim doc   
Set doc = Server.CreateObject("Msxml2.DOMDocument.3.0")   
doc.async = False  
If doc.load(Server.MapPath("ee.xml")) Then   

  doc.setProperty "SelectionLanguage", "XPath"    

for i= 1 to 3 '2 is noofrooms

adult1 ="1"
child1 ="0"
adult2 ="2"
child2 ="1"
adult3 ="3"
child3 ="0"
'adult4 ="4"
'child4 ="0"


for d=0 to 4 ' total nodes ( /rooms)

' this for 2 room cause
'ds ="(//HotelDetails/hotel/rooms/room[Adult='"&adult1&"' and child='"&child1&"'])["&i&"]|(//HotelDetails/hotel/rooms/room[Adult='"&adult2&"' and child='"&child2&"'])["&d&"]" 

' this for 3 room cause
ds ="(//HotelDetails/hotel/rooms/room[(Adult='"&adult1&"' and child='"&child1&"') ])["&i&"]|((//HotelDetails/hotel/rooms/room[(Adult='"&adult2&"' and child='"&child2&"')])|(//HotelDetails/hotel/rooms/room[(Adult='"&adult3&"' and child='"&child3&"')]))["&d&"]"


' this for 4 room cause
'ds ="(//HotelDetails/hotel/rooms/room[(Adult='"&adult1&"' and child='"&child1&"') ])["&i&"]|((//HotelDetails/hotel/rooms/room[(Adult='"&adult2&"' and child='"&child2&"')])|(//HotelDetails/hotel/rooms/room[(Adult='"&adult3&"' and child='"&child3&"')])|(//HotelDetails/hotel/rooms/room[(Adult='"&adult3&"' and child='"&child3&"')]))["&d&"]"



Set colNodes=doc.selectNodes (ds)
For Each objNode in colNodes

  response.write objNode.Text & VbCrLf 

Next

next


next

Else   
  Response.Write doc.parseError.reason   
End If

Plz help me to (take output) solve this problem thanks

2009-06-16 07:55
by Alex
How is this question different from the question you posted here? http://stackoverflow.com/questions/992425/sort-xml-data-in-classic-as - jitter 2009-06-16 08:00
I think so. Close as duplicate suggeste - jitter 2009-06-16 08:03
@Alex: you were asked some sensible questions in comments to your previous post, which failed to answer. This question you've made your intentions clearer. You should either delete the previous question or edit it adding the details you have here and delete this question. Note SO is not a sequential forum or NG, you can evolve existing questions to make the better - AnthonyWJones 2009-06-16 11:34
Oh and while your are at it, can you indent your code by 4 spaces that way it will get formatted as code and we can read it better - AnthonyWJones 2009-06-16 11:35
@AnthonyWJones: Four spaces? That's heretic! Code must not be indented by anything other than two spaces, everyone knows that. ;- - Tomalak 2009-06-16 11:59
@Tomalak: I wish! I'm the only one in my team that wants to use 2 space indent (using the tab character in an attempt to keep the 4 spacers happy) but everyone else insists in 4 actual spaces :( Still I was refering to the initial 4 spaces (or a tab) that triggers SO's code prettyfier - AnthonyWJones 2009-06-16 14:44


0

Is this a repeat of: Sort XML data in classic ASP ?

2009-06-16 08:00
by Sev
i not get a currect solution , th's why i post again.. sorr - Alex 2009-06-16 08:13