Fandom

Scratchpad

Segments: XmlHTTP

216,238pages on
this wiki
Add New Page
Discuss this page0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Introduction to XmlHTTP

The XmlHTTP object is a control that can be used to send and retrieve data to and from a webpage. Here are a couple different implementations of the object!

Basic Page Source Retrieval

address = "your address here"
Dim xmlhttp
Set xmlhttp = CreateObject("Microsoft.XmlHttp")
xmlhttp.Open "GET",address,False ' Note the use of the 'address' variable here.
xmlhttp.send ""
PageSource = xmlhttp.responseText

Sending Data to a Web Form

address = "form submission address"
' Arguments seperated by ampersands.
arguments = "argument1=this&argument2=that&morearguments=continued"
Dim xmlhttp
Set xmlhttp = CreateObject("Microsoft.XmlHttp")
' Note the use of the 'address' variable here, and the POST method!
xmlhttp.Open "POST",address,False
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
' Sends the arguments variable, which will be parsed by the form engine as POST data.
xmlhttp.send arguments
PageSource = xmlhttp.responseText

Search for a string in page source

The following snippet is an example of searching a webpage source for a string using an XMLHttp object.

Sub search_webpage
 ' Load the webpage into a XMLHttp Object 
 url_s = "webpage to search"
 Set xmlhttp = CreateObject("Microsoft.XmlHttp")
 xmlhttp.Open "GET", url_s, False
 xmlhttp.Send

 ' Search the loaded page
 strSearchThis = xmlhttp.responseText
 If instr(strSearchThis, "string to search for") <> 0 Then
  'string is found 
 End If
				
 Set xmlhttp = nothing
End Sub

Comments/Suggestions

As of DesktopX 3.2 you can use System.DownloadFile(remoteUrl, localPath, bAsync) and System.SendRequest(remoteUrl, postParams, bAsync) to perform the same operations as described earlier. These integrated functions should behave more friendly with some virus scanners that might otherwise complain.

Also on Fandom

Random wikia