Inspired? No home

Get a file from another server

The Microsoft XML Parser includes an object called XMLHTTP. Though the name says XML it has little to do with XML except for one function that makes it possible to retreive a document as XML. The essential use of XMLHTTP is to send HTTP requests and retrive the response. It is quite simple to use and it's very easy to do a simple task like get a file from another server:

dim objXMLHTTP, url
set objXMLHTTP = server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
url = ""
objXMLHTTP.Open "GET", url, false
response.Write objXMLHTTP.responseText
set objXMLHTTP = nothing

Note: This is for use with ASP. Notice the Server in the object. That's the server-safe version of XMLHTTP. When using client-side JavaScript use the MSXML2.XMLHTTP.4.0 instead. Also remember that there are many versions of the XML Parser around, so don't use the 4.0 version if the user doesn't have it installed. I recommend using the MS XML Parser sniffer to get the correct version installed - see my article here.

See this page at PerfectXML for more information.

Written on 26 July 2004.
blog comments powered by Disqus