|
-
Jun 16th, 2010, 08:19 AM
#1
Thread Starter
Junior Member
get XML from php into vb6, possible?
http://www.f1project.org/xml/laboratorio.php
shows us a XML file but it dosent end in .xml and i dont know why,
but is it possible to get vb6 to read the xml? and if so how?
thanks
-
Jun 16th, 2010, 08:38 AM
#2
Re: get XML from php into vb6, possible?
I get an error when I open that. Maybe you can open the link in a WebBrowser control and get the XML from page source.
-
Jun 16th, 2010, 09:12 AM
#3
Thread Starter
Junior Member
Re: get XML from php into vb6, possible?
oh you have to be logged into the website.
-
Jun 16th, 2010, 09:18 AM
#4
Re: get XML from php into vb6, possible?
it doesn't end in xml because what you are accessing is a PHP file... it just so happens that the php file then returns an XML document. Having to be logged into the website adds a bit of complexity... and I'm not sure quite how to deal with that.
-tg
-
Jun 16th, 2010, 01:13 PM
#5
Thread Starter
Junior Member
Re: get XML from php into vb6, possible?
well logging in from the program is something i might try at a later date, at the moment i'm just happy with loggin in in my browser, and then reading the xml doc.
apparently its because the file is dynamically generated
still stuck
-
Jun 17th, 2010, 08:50 AM
#6
Thread Starter
Junior Member
Re: get XML from php into vb6, possible?
think i am getting it to read the url now,
just trying to get a textbox to display the value of a node
but it bugs when trying to find the node
any ideas where i might be going wrong?
vb Code:
Private Sub Command46_Click() Dim objXML As MSXML2.DOMDocument Dim objElem As MSXML2.IXMLDOMElement Set objXML = New MSXML2.DOMDocument If objXML.Load("http://www.f1project.org/xml/laboratorio.php") = False Then MsgBox ("XML LOAD ERROR") Else Set objElem = objXML.selectSingleNode("//LaboratoryAeroPrice") <------ it bugs here Text4.Text = objElem.getAttribute("value") End If End Sub
-
Jun 17th, 2010, 08:52 AM
#7
Thread Starter
Junior Member
Re: get XML from php into vb6, possible?
a bit of the xml i'm trying to use:
<Laboratory>
<LaboratoryAeroInv>0</LaboratoryAeroInv>
<LaboratoryElectInv>5000</LaboratoryElectInv>
<LaboratoryMotorInv>15000</LaboratoryMotorInv>
<LaboratoryTyresInv>15000</LaboratoryTyresInv>
<LaboratoryGearInv>0</LaboratoryGearInv>
<LaboratorySuspenInv>25000</LaboratorySuspenInv>
<LaboratoryBrakeInv>15000</LaboratoryBrakeInv>
<LaboratoryAeroLev>1</LaboratoryAeroLev>
<LaboratoryElectLev>8</LaboratoryElectLev>
<LaboratoryMotorLev>11</LaboratoryMotorLev>
<LaboratoryTyresLev>11</LaboratoryTyresLev>
<LaboratoryGearLev>1</LaboratoryGearLev>
<LaboratorySuspenLev>12</LaboratorySuspenLev>
<LaboratoryBrakeLev>10</LaboratoryBrakeLev>
<LaboratoryPieceBuilded>5</LaboratoryPieceBuilded>
<LaboratoryAeroBuilded>0</LaboratoryAeroBuilded>
<LaboratoryElectBuilded>1</LaboratoryElectBuilded>
<LaboratoryMotorBuilded>1</LaboratoryMotorBuilded>
<LaboratoryTyresBuilded>1</LaboratoryTyresBuilded>
<LaboratoryGearBuilded>0</LaboratoryGearBuilded>
<LaboratorySuspenBuilded>1</LaboratorySuspenBuilded>
<LaboratoryBrakeBuilded>1</LaboratoryBrakeBuilded>
<LaboratoryAeroPrice>2525</LaboratoryAeroPrice>
<LaboratoryElectPrice>8742</LaboratoryElectPrice>
<LaboratoryMotorPrice>38651</LaboratoryMotorPrice>
<LaboratoryTyresPrice>12704</LaboratoryTyresPrice>
<LaboratoryGearPrice>2525</LaboratoryGearPrice>
<LaboratorySuspenPrice>25264</LaboratorySuspenPrice>
<LaboratoryBrakePrice>29946</LaboratoryBrakePrice>
</Laboratory>
-
Jun 17th, 2010, 08:59 AM
#8
Re: get XML from php into vb6, possible?
I think you are getting the error because of this line
If objXML.Load("http://www.f1project.org/xml/laboratorio.php")
If I am not wrong, then the syntax is
If Not objXML.loadXML(strXML) Then
Where strXML is a string variable which stores XML and not a website address...
Example
Code:
strXML = "<JustAnExample><Node Name=""tag666""/><group name=""VBF""><another value=""VBForums""/></group></JustAnExample>"
Regarding the code in post 6, I don't see any syntax errors...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jun 17th, 2010, 09:18 AM
#9
Thread Starter
Junior Member
Re: get XML from php into vb6, possible?
i used to think it was that line, but wouldn't it come up with that msgbox if it couldn't load it?
but i'm using a url and how would i update the xml data from the url into a string automatically?,
seems a bit pointless, there must be a way to just use the url?
-
Jun 17th, 2010, 09:26 AM
#10
Re: get XML from php into vb6, possible?
Can you try this for me and tell me what happens?
Code:
Private Sub Command46_Click()
Dim objXML As MSXML2.DOMDocument
Dim objElem As MSXML2.IXMLDOMElement
Dim strXML As String
Set objXML = New MSXML2.DOMDocument
strXML = "<Laboratory><LaboratoryAeroInv>0</LaboratoryAeroInv><LaboratoryAeroPrice>2525</LaboratoryAeroPrice></Laboratory>"
If objXML.LoadXML(strXML) = False Then
MsgBox ("XML LOAD ERROR")
Else
Set objElem = objXML.selectSingleNode("//LaboratoryAeroPrice")
Text4.Text = objElem.getAttribute("value")
End If
End Sub
Last edited by Siddharth Rout; Jun 17th, 2010 at 09:57 AM.
Reason: Typo
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jun 17th, 2010, 09:35 AM
#11
Re: get XML from php into vb6, possible?
koolsid - there's two methods to load - Load which takes a filepath OR a URL to an XML doc... so that part is OK. LoadXML is a DIFFERENT function, that, like you mentioned, takes an XML string...
In this case the Load (with the url) is the appropriate syntax.
The reason objXML.selectSingleNode("//LaboratoryAeroPrice") fails is because the xPath query is wrong.
LaboratoryAeroPrice isn't a root node... Laboratory is the root node... so to get to the AeroPrice, the selection should be:
objxml.documentElement.selectSingleNode("/Laboratory/LaboratoryAeroPrice")
I find that selecting right off the document doesn't seem to work, but going through the documentElelment object does.... go figure.
-tg
-
Jun 17th, 2010, 09:54 AM
#12
Thread Starter
Junior Member
Re: get XML from php into vb6, possible?
with koolsid's get the msgbox.
with techgnome i get an error saying "Object variable or With block variable not set"
-
Jun 17th, 2010, 09:58 AM
#13
Re: get XML from php into vb6, possible?
I had made a typo in the last post. Try it now
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jun 17th, 2010, 10:39 AM
#14
Thread Starter
Junior Member
Re: get XML from php into vb6, possible?
ok that gets to the getAttribute bit but it errors and says "invalid use of Null"
but i want it from a url
-
Jun 17th, 2010, 10:56 AM
#15
Re: get XML from php into vb6, possible?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jun 17th, 2010, 11:08 AM
#16
Re: get XML from php into vb6, possible?
That's because it isn't an attribute.... once you have the node, you should be able to get the value through .Value or .InnerHTML ...
-tg
-
Jun 17th, 2010, 11:53 AM
#17
Thread Starter
Junior Member
Re: get XML from php into vb6, possible?
with techgnome i get an error saying "Object variable or With block variable not set"
Text4.Text = objElem.Value
Text4.Text = objElem.InnerHTML
both dont work
Last edited by tag666; Jun 17th, 2010 at 12:00 PM.
-
Jun 22nd, 2010, 07:58 AM
#18
Thread Starter
Junior Member
Re: get XML from php into vb6, possible?
i still cant get the value into the textbox?
any ideas?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|