VBA - responseXML to a QueryTable?

mmohon

New Member
Joined
Nov 19, 2009
Messages
38
I'm using the API of a website to pull some data down. I get a good responseXML from it.

Is there a way I can drop that responseXML data into a querytable, just as if I was importing data from an xml file?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
How exactly are you getting the responseXML?

Have you tried writing it to a file then using the 'normal' methods to import it as a query table?
 
Upvote 0
Code:
Set objhttp = CreateObject("MSXML2.ServerXMLHTTP")
   URL = my url
   objhttp.Open "GET", URL, False
   objhttp.setRequestHeader "ApiKey", mykey
   objhttp.send

From there I can do msgbox(responseText) and see what's returned. It's all the XML data. I was hoping I could just drop the responseXML into a table.
 
Upvote 0
The only way I can see it being done with a query table would be if the response was written to a file.

By the way, what website/API are you using - I only have local XML files to test on so might be missing something really obvious.
 
Upvote 0
How could I drop that to a file then?

I could see:

Export to a file.xml
Import from the file into a query table
break connection
delete file.xml

Does that seem possible?
 
Upvote 0
Just write it to a file using VBA File I/O methods.

Something like this perhaps.
Code:
              Dim FF As Long
 
       FF = FreeFile()
 
       Open "C:\apiresponse.xml" For Output As FF
            Write #FF, oXMLHTTP.responseXML.XML
       Close #FF
That will output responseXML to a file but I don't have anything to test it with, so I don't know if it's any use.

Can you post the website/API?
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,903
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top