Link to home
Start Free TrialLog in
Avatar of Scott Kricho
Scott KrichoFlag for United States of America

asked on

Parsing XML data in VB6

Hello.

I am trying to access XML data in a VB6 application. The XML data is being returned from API calls to a cloud based service.

License.GetActivationKeyFromUserData and License.ActivateLicense are both API calls that return XML data to keyResponse and licenseResponse.

Dim ActivationKey As String
Dim newLicense As String
Dim keyResponse As String
Dim licenseResponse As String
       
ActivationKey = License.GetActivationKeyFromUserData("", "test", keyResponse)
newLicense = License.ActivateLicense("", ActivationKey, Environ("computername"), Environ("computername"), "5.0.00", "", licenseResponse)

After the License.GetActivationKeyFromUserData call, keyResponse returns:

<?xml version="1.0" encoding="utf-8"?> <QuickLicenseManager><result>BNR4060200G1HJKM8P9Q115DC95TCZFDPEDSVF6</result> <avkey>BNR4060200G1HJKM8P9Q115DC95TCZFDPEDSVF6</avkey> </QuickLicenseManager>

And ActivationKey equals 'BNR4060200G1HJKM8P9Q115DC95TCZFDPEDSVF6'

After the License.ActivateLicense call, licenseResponse returns:

<?xml version="1.0" encoding="utf-8"?> <QuickLicenseManager><avkey>BNR4060200G1HJKM8P9Q115DC95TCZFDPEDSVF6</avkey> <pckey>VNR6020200G2HJKM8P9Q115ERSU8AS8KYV2PS7D</pckey> <computerID>WIN-BES33JO9GB9</computerID> <computerName>WIN-BES33JO9GB9</computerName> <features>0:2;</features> <userCompany>Krihos International</userCompany> <userFullName>Scott Kricho</userFullName> <userEmail>scott@axlms.com</userEmail> <licenseModel>subscription</licenseModel> </QuickLicenseManager>

And newLicense equals an empty string.

What is the proper way for handling XML data in VB6?
Avatar of zc2
zc2
Flag of United States of America image

To load the XML, try:
        Dim doc As XmlDocument = New XmlDocument()
        doc.LoadXML keyResponse 

Open in new window

Then you can query for a node, like the following:
Dim avkeyNode As XmlNode
set avkeyNode = doc.SelectSingleNode("/QuickLicenseManager/avkey")
ActivationKey  = avkeyNode.innerText

Open in new window

Avatar of Scott Kricho

ASKER

Thank you zc2, But the statement doc.LoadXML keyResponse throws error 438: Object doesn't support this property or method. Here's my code:

        Dim ActivationKey As String
        Dim newLicense As String
        Dim keyResponse As String
        Dim licenseResponse As String
       
        ActivationKey = License.GetActivationKeyFromUserData("", "test", keyResponse)
       
        Dim doc As XMLDocument
        Set doc = New XMLDocument
        doc.loadXML keyResponse
ASKER CERTIFIED SOLUTION
Avatar of zc2
zc2
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks zc2! That did the trick.
You are welcome!