shwaqar82
asked on
display result from xml file
Hi Experts
I have the following xml:
<?xml version="1.0"?>
<!--This Is A List Of Dream Vacations Special Packages-->
<HOTELS>
<HOTEL>
<DEPARTURE>Toronto</DEPART URE>
<DESTINATION>Cancun</DESTI NATION>
<NAME>AKUMAL BEACH RESORT</NAME>
<LINK>http://webstar.softvoyage.com/cgi-bin/hotel_desc.cgi?sun&&http://webstar.softvoyage.com/hotels/VACen/AKUMCUN.html</LINK>
<STAR>3</STAR>
<ROOM>STD-GARD</ROOM>
<MEAL>AI</MEAL>
<DATE>NOV-15-2006</DATE>
<DURATION>7</DURATION>
<PRICE>$822.00</PRICE>
<SID>112086a3259303c76d123 e67e7004be 2</SID>
<URL>http://sun.sax.softvoyage.com/cgi-bin/resultsforf.cgi?sid=112086a3259303c76d123e67e7004be2</URL>
</HOTEL>
<HOTEL>
<DEPARTURE>Toronto</DEPART URE>
<DESTINATION>Cancun</DESTI NATION>
<NAME>AKUMAL BEACH RESORT</NAME>
<LINK>http://webstar.softvoyage.com/cgi-bin/hotel_desc.cgi?sun&&http://webstar.softvoyage.com/hotels/VACen/AKUMCUN.html</LINK>
<STAR>3</STAR>
<ROOM>SUP</ROOM>
<MEAL>AI</MEAL>
<DATE>NOV-15-2006</DATE>
<DURATION>7</DURATION>
<PRICE>$863.00</PRICE>
<SID>112086a3259303c76d123 e67e7004be 2</SID>
<URL>http://sun.sax.softvoyage.com/cgi-bin/resultsforf.cgi?sid=112086a3259303c76d123e67e7004be2</URL>
</HOTEL>
</HOTELS>
And im using the following code which should display the result of each node on the page but it gives me the result of first node every time. Im using the following code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim doc As New XmlDocument
Dim hotelNodes As XmlNodeList
Dim node As XmlNode
Dim strDep, strDes, strName, strLink, strStar, strRoom, strMeal, strDate, strDuration, strPrice, strSID, strURL As String
Dim lbl As Label
Dim hl As HyperLink
Dim tbl As New Table
Dim tr As TableRow
Dim tc As TableCell
Dim i As Integer
doc.Load("C:\Inetpub\wwwro ot\CallFor m\Specials \special.x ml")
hotelNodes = doc.SelectNodes("//HOTELS/ HOTEL")
i = 1
For Each node In hotelNodes
strDep = node.SelectSingleNode("//D EPARTURE") .InnerText
strDes = node.SelectSingleNode("//D ESTINATION ").InnerTe xt
strName = node.SelectSingleNode("//N AME").Inne rText
strLink = node.SelectSingleNode("//L INK").Inne rText
strStar = node.SelectSingleNode("//S TAR").Inne rText
strRoom = node.SelectSingleNode("//R OOM").Inne rText
strMeal = node.SelectSingleNode("//M EAL").Inne rText
strDate = node.SelectSingleNode("//D ATE").Inne rText
strDuration = node.SelectSingleNode("//D URATION"). InnerText
strPrice = node.SelectSingleNode("//P RICE").Inn erText
strSID = node.SelectSingleNode("//S ID").Inner Text
strURL = node.SelectSingleNode("//U RL").Inner Text
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "<br>Departure: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strDep & "</b></br>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Destination: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strDes & "</b></br>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Hotel: "
tc.Controls.Add(lbl)
hl = New HyperLink
hl.ID = "h1" & i
hl.Text = strName
hl.NavigateUrl = strLink
tc.Controls.Add(hl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Star Rating: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strStar & "</b>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Room Type: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strRoom & "</b>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Meal: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strMeal & "</b>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Date: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strDate & "</b>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Duration: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strDuration & "</b>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Price: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strPrice & "</b>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
hl = New HyperLink
hl.ID = "h2" & i
hl.NavigateUrl = strURL
'hl.NavigateUrl = "http://sun.sax.softvoyage.com/cgi-bin/input-verifforf.cgi?sid=" & strSID
hl.Text = "<b>" & "Request Space" & "</b></br>"
tc.Controls.Add(hl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
i += 1
Next
Page.Controls.Add(tbl)
End Sub
This code traverse through each node but displaying the values of first node every time. Can anyone help me..?
Best Regards
Shaukat
I have the following xml:
<?xml version="1.0"?>
<!--This Is A List Of Dream Vacations Special Packages-->
<HOTELS>
<HOTEL>
<DEPARTURE>Toronto</DEPART
<DESTINATION>Cancun</DESTI
<NAME>AKUMAL BEACH RESORT</NAME>
<LINK>http://webstar.softvoyage.com/cgi-bin/hotel_desc.cgi?sun&&http://webstar.softvoyage.com/hotels/VACen/AKUMCUN.html</LINK>
<STAR>3</STAR>
<ROOM>STD-GARD</ROOM>
<MEAL>AI</MEAL>
<DATE>NOV-15-2006</DATE>
<DURATION>7</DURATION>
<PRICE>$822.00</PRICE>
<SID>112086a3259303c76d123
<URL>http://sun.sax.softvoyage.com/cgi-bin/resultsforf.cgi?sid=112086a3259303c76d123e67e7004be2</URL>
</HOTEL>
<HOTEL>
<DEPARTURE>Toronto</DEPART
<DESTINATION>Cancun</DESTI
<NAME>AKUMAL BEACH RESORT</NAME>
<LINK>http://webstar.softvoyage.com/cgi-bin/hotel_desc.cgi?sun&&http://webstar.softvoyage.com/hotels/VACen/AKUMCUN.html</LINK>
<STAR>3</STAR>
<ROOM>SUP</ROOM>
<MEAL>AI</MEAL>
<DATE>NOV-15-2006</DATE>
<DURATION>7</DURATION>
<PRICE>$863.00</PRICE>
<SID>112086a3259303c76d123
<URL>http://sun.sax.softvoyage.com/cgi-bin/resultsforf.cgi?sid=112086a3259303c76d123e67e7004be2</URL>
</HOTEL>
</HOTELS>
And im using the following code which should display the result of each node on the page but it gives me the result of first node every time. Im using the following code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim doc As New XmlDocument
Dim hotelNodes As XmlNodeList
Dim node As XmlNode
Dim strDep, strDes, strName, strLink, strStar, strRoom, strMeal, strDate, strDuration, strPrice, strSID, strURL As String
Dim lbl As Label
Dim hl As HyperLink
Dim tbl As New Table
Dim tr As TableRow
Dim tc As TableCell
Dim i As Integer
doc.Load("C:\Inetpub\wwwro
hotelNodes = doc.SelectNodes("//HOTELS/
i = 1
For Each node In hotelNodes
strDep = node.SelectSingleNode("//D
strDes = node.SelectSingleNode("//D
strName = node.SelectSingleNode("//N
strLink = node.SelectSingleNode("//L
strStar = node.SelectSingleNode("//S
strRoom = node.SelectSingleNode("//R
strMeal = node.SelectSingleNode("//M
strDate = node.SelectSingleNode("//D
strDuration = node.SelectSingleNode("//D
strPrice = node.SelectSingleNode("//P
strSID = node.SelectSingleNode("//S
strURL = node.SelectSingleNode("//U
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "<br>Departure: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strDep & "</b></br>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Destination: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strDes & "</b></br>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Hotel: "
tc.Controls.Add(lbl)
hl = New HyperLink
hl.ID = "h1" & i
hl.Text = strName
hl.NavigateUrl = strLink
tc.Controls.Add(hl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Star Rating: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strStar & "</b>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Room Type: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strRoom & "</b>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Meal: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strMeal & "</b>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Date: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strDate & "</b>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Duration: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strDuration & "</b>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
lbl = New Label
lbl.ID = "lbl" & i
lbl.Text = "Price: "
tc.Controls.Add(lbl)
lbl = New Label
lbl.ID = "lbl2" & i
lbl.Text = "<b>" & strPrice & "</b>"
tc.Controls.Add(lbl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
tr = New TableRow
tc = New TableCell
hl = New HyperLink
hl.ID = "h2" & i
hl.NavigateUrl = strURL
'hl.NavigateUrl = "http://sun.sax.softvoyage.com/cgi-bin/input-verifforf.cgi?sid=" & strSID
hl.Text = "<b>" & "Request Space" & "</b></br>"
tc.Controls.Add(hl)
tr.Cells.Add(tc)
tbl.Rows.Add(tr)
i += 1
Next
Page.Controls.Add(tbl)
End Sub
This code traverse through each node but displaying the values of first node every time. Can anyone help me..?
Best Regards
Shaukat
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i did that but still gives me the same result
ASKER
Hi Geert
It works now thanks for you precious help on time.
Best Regards
Shaukat
It works now thanks for you precious help on time.
Best Regards
Shaukat
ASKER
Can you help me in displaying the nodes information row wise. I mean i wana display the information like below:
Hotel 1 Information Hotel 2 Information
Hotel 3 Information Hotel 4 Information
Hotel 5 Information
Right now it displays the information like that:
Hotel 1 Info.
Hotel 2 Info.
Hotel 3 Info.
....
That would be great if you fixed it.
Best Regards
Shaukat Waqar
Hotel 1 Information Hotel 2 Information
Hotel 3 Information Hotel 4 Information
Hotel 5 Information
Right now it displays the information like that:
Hotel 1 Info.
Hotel 2 Info.
Hotel 3 Info.
....
That would be great if you fixed it.
Best Regards
Shaukat Waqar
Hi,
I am not really a VB (script) programmer
What you could do is the following
For Each node In hotelNodes
you could only loop over the hotelNodes with a position mod 2 = 1
and so create the rows
and pick the following node inside the row
If you can't manage that yourself, you can post in the VB(script) TA
cheers
I am not really a VB (script) programmer
What you could do is the following
For Each node In hotelNodes
you could only loop over the hotelNodes with a position mod 2 = 1
and so create the rows
and pick the following node inside the row
If you can't manage that yourself, you can post in the VB(script) TA
cheers
get rid of the "//" in the childnodes
strDep = node.SelectSingleNode("DEP
Cheers!