Using XMLHTTP in VBScript


Ajax stands for Asynchronous Javascript and Xml. In the examples given in this post, we can see that XMLHTTP object is created, for IE6 and IE5. The XMLHTTP object can be used in VBScript to access the remote file. The following is an easy example in Window Scripting Hosting (WSH) environment.

One of the powerfulness of VBScript is that it can create COM objects, therefore, you can basically do powerful stuffs using VBScript. Ajax is just one of the examples.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
' Save an RSS Feed to a Text File
 
Const ForWriting = 2
 
strURL="http://blogs.msdn.com/gstemp/Rss.aspx"
Set objHTTP = CreateObject("MSXML2.XMLHTTP") 
Call objHTTP.Open("GET", strURL, FALSE) 
objHTTP.Send
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile _
    ("C:\scripting_guys.xml", ForWriting)
objFile.Write objHTTP.ResponseText
objFile.Close
' Save an RSS Feed to a Text File

Const ForWriting = 2

strURL="http://blogs.msdn.com/gstemp/Rss.aspx"
Set objHTTP = CreateObject("MSXML2.XMLHTTP") 
Call objHTTP.Open("GET", strURL, FALSE) 
objHTTP.Send

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile _
    ("C:\scripting_guys.xml", ForWriting)
objFile.Write objHTTP.ResponseText
objFile.Close

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
207 words
Last Post: Auto-Generate a File Name in VBScript
Next Post: Codeforces: 300A. Array

The Permanent URL is: Using XMLHTTP in VBScript

Leave a Reply