Results 1 to 18 of 18

Thread: get XML from php into vb6, possible?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    17

    Question 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

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    17

    Re: get XML from php into vb6, possible?

    oh you have to be logged into the website.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    17

    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

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    17

    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:
    1. Private Sub Command46_Click()
    2.  
    3. Dim objXML As MSXML2.DOMDocument
    4. Dim objElem As MSXML2.IXMLDOMElement
    5. Set objXML = New MSXML2.DOMDocument
    6.  
    7. If objXML.Load("http://www.f1project.org/xml/laboratorio.php") = False Then
    8. MsgBox ("XML LOAD ERROR")
    9. Else
    10. Set objElem = objXML.selectSingleNode("//LaboratoryAeroPrice")      <------ it bugs here
    11. Text4.Text = objElem.getAttribute("value")
    12.  
    13. End If
    14.  
    15. End Sub

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    17

    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>

  8. #8
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    17

    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?

  10. #10
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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

  11. #11
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    17

    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"

  13. #13
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    17

    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

  15. #15
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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

  16. #16
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  17. #17

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    17

    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.

  18. #18

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    17

    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
  •  



Click Here to Expand Forum to Full Width