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?
Scott KrichoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zc2Commented:
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

0
Scott KrichoAuthor Commented:
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
0
zc2Commented:
I might confused VB6 with VB.net
Try this:
Dim doc As New MSXML2.DOMDocument
doc.loadXML keyResponse

Open in new window

or
Dim doc As MSXML2.DOMDocument
Set doc = CreateObject("MSXML2.DOMDocument")
doc.loadXML keyResponse

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott KrichoAuthor Commented:
Thanks zc2! That did the trick.
0
zc2Commented:
You are welcome!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
vb6

From novice to tech pro — start learning today.