Link to home
Start Free TrialLog in
Avatar of Mike Caldwell
Mike CaldwellFlag for United States of America

asked on

How to read the XML data returned from an API with VB Script?

I am trying to learn a bit more about VB scripting, as well as better understand how a client would use a simple API I have parked at a web site I own and have hosted at a cloud server.  I can successfully access the URL (no credentials needed at this point) and properly submit the requested fields and operand.  What comes back is a bunch of API text to my monitor.  I need to know how to capture the stream without it being displayed, and then use the saved page of XML lines as TXT so that I can have my script then pick off what I want and present it in a MSGBOX.

Here is what successfully accesses it:

  Set oShell = CreateObject("Wscript.Shell")
  oShell.Exec "C:\Program Files\Internet Explorer\iexplore.exe https://api.niftywebsite.net/?opts=WORD1&whatiwant=123456"

Here is what I get back in my browser:

<?xml version="1.0" encoding="UTF-8"?>
-<response>
-<entity>
<whatiwant>123456</whatiwant>
<WORD1>Just some test stuff</WORDS1>
</entity>
</response>

So can I suppress the monitor echo and pipe the XML text to a file?  Better would be if I could just hold the text and access it without a file save / open / read.
ASKER CERTIFIED SOLUTION
Avatar of ltlbearand3
ltlbearand3
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
Avatar of Mike Caldwell

ASKER

Perfect!  Exactly what I was looking for.  I frankly don't understand all of the code, but I'll let Mr. Google teach me the details.  Thanks so much.