Re: Convert Error from VB6
Quote:
Originally Posted by
deve
I have converted my old project from VB6 to VB2008 but there is an uggly error that I chould not resolve.
It whould be great if some one can help me . My error shows this line :
Code:
DebugXML.Text = Inet1.OpenURL("http://
it can not accept this argument ?
I don't suppose VB6 would either if that line is complete! Assuming it does end logically and that DebugXML.Text is a textbox(?), what is Inet1 and what are you actually wanting this to do?
Re: Convert Error from VB6
this is all of the code :
Code:
DebugXML.Text = Inet1.OpenURL("http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/driver/" & Text2.Text & "/cars")
xml_document.loadXML(DebugXML.Text)
xm1_node = xml_document.getElementsByTagName("worldCar")
xm2_node = xml_document.getElementsByTagName("physicsProfile")
DebugXML.Text = CStr(CDbl(xm1_node(0).Text) + xm2_node(0).Text)
Re: Convert Error from VB6
Well that makes it a bit clearer. No, VB.Net doesn't handle XML files in that way. There are actually a number of different ways to approach XML. The following, which exploits .Net's inbuilt LINQ support, may be instructive. If not, there are many references on the net. Stick to the most recent!
vb.net Code:
Dim doc As XDocument
doc = XDocument.Load("http://dl.dropbox.com/u/8842115/sample.xml")
For Each node In doc.Descendants("first")
DebugXML.AppendText((CType(node.Element("name"), String)) & vbCrLf)
Next
xml Code:
<root>
<first>
<no>10</no>
<name>mr. a</name>
</first>
<first>
<no>20</no>
<name>mr. b</name>
</first>
</root>
Re: Convert Error from VB6
I am not getting it correctly sorry , how whould I go with this xml output if I wont to have the nodes : carID - make - carName - acceleration - handling - rating - topspeed - carclass ?
<worldCar carId="14717367" make="CAR_MANU_MITSUBISHI" carName="CAR_MDL_ECLIPSEGT">
<physicsProfile acceleration="219" handling="300" rating="254" topSpeed="243" carClass="carclass_d"/>
</worldCar>-
P.S I start to use VS 2010
Re: Convert Error from VB6
One way ... you can tidy it up once you've seen how it works ...
vb.net Code:
For Each node In doc.Descendants("worldCar")
Dim ss As String() = Split(node.ToString, " ")
For i = 0 To ss.Length - 1
DebugXML.AppendText(i.ToString & " " & ss(i) & vbCrLf)
Next
Next
Re: Convert Error from VB6
ok my result code looks like this :
Code:
Dim doc As XDocument
doc = XDocument.Load("http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/driver/nfswdriver/car")
For Each node In doc.Descendants("worldCar")
Dim ss As String() = Split(node.ToString, " ")
For i = 0 To ss.Length - 1
TextBox2.Text = (i.ToString & " " & ss(i) & vbCrLf)
Next
Next
result that I get is this only :
12 />
</worldCar>
Re: Convert Error from VB6
Final code looks like this :
Code:
Dim doc As XDocument
doc = XDocument.Load("http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/driver/" + TextBox1.Text + "/car")
For Each node In doc.Descendants("worldCar")
Dim ss As String() = Split(node.ToString, "carId")
For i = 0 To ss.Length - 1
TextBox2.Text = " Drivers Name : " + TextBox1.Text + vbCrLf + (i.ToString & " " & ss(i) & vbCrLf)
Next
Next
output looks like this :
PHP Code:
Drivers Name : nfswdev
1 ="13512645" make="CAR_MANU_DODGE" carName="CAR_MDL_CHARGER07BEE">
<physicsProfile acceleration="547" handling="247" rating="406" topSpeed="426" carClass="carclass_c" />
</worldCar>
What is the 1 in the beginning ? and how can I put all the nodes 1 by 1 in line. like
car id : result
acceleration : result
and so on
the real XML output on the webpage is like this :
PHP Code:
<worldCar carId="13512645" make="CAR_MANU_DODGE" carName="CAR_MDL_CHARGER07BEE">
<physicsProfile acceleration="547" handling="247" rating="406" topSpeed="426" carClass="carclass_c"/>
</worldCar>
Re: Convert Error from VB6
Er ... yes ... slight difference between ....
DebugXML.AppendText(i.ToString & " " & ss(i) & vbCrLf)
and
TextBox2.Text = (i.ToString & " " & ss(i) & vbCrLf)