views:

531

answers:

1

hi, this is my xml

 <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

A: 

Is this a repeat of: http://stackoverflow.com/questions/992425/sort-xml-data-in-classic-asp-using-vbscript ?

Sev
i not get a currect solution , th's why i post again.. sorry
Alex