Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.



Provides client-side protocol support for communication with HTTP servers.

The following Microsoft® JScript® example creates an XMLHTTP object and asks a server for an XML document. The server sends back an XML document, which is then displayed in a message box.

var xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.6.0");"GET", "http://localhost/books.xml", false);  

The following C/C++ example creates an XMLHTTP object and asks a server for an XML document. The server sends back an XML document that is displayed by the code snippet.

#import "msxml6.dll"  
using namespace MSXML2;  
void XMLHttpRequestSample()  
   IXMLHTTPRequestPtr pIXMLHTTPRequest = NULL;  
   BSTR bstrString = NULL;  
   HRESULT hr;  
   try {  
      SUCCEEDED(hr) ? 0 : throw hr;  
      hr=pIXMLHTTPRequest->open("GET", "http://localhost/books.xml ", false);  
      SUCCEEDED(hr) ? 0 : throw hr;  
      SUCCEEDED(hr) ? 0 : throw hr;  
      MessageBox(NULL, _bstr_t(bstrString), _T("Results"), MB_OK);  
         bstrString = NULL;  
   } catch (...) {  
      MessageBox(NULL, _T("Exception occurred"), _T("Error"), MB_OK);  

A client computer can use the XMLHTTP object (MSXML2.XMLHTTP.3.0) to send an arbitrary HTTP request, receive the response, and have the Microsoft® XML Document Object Model (DOM) parse that response.

This object is integrated with Microsoft XML Core Services (MSXML) to support sending the request body directly from, and parsing the response directly into, the MSXML DOM objects. When combined with the support for Extensible Stylesheet Language (XSL), the XMLHTTP component provides an easy way to send structured queries to HTTP servers and efficiently display the results with a variety of presentations.

The usual sequence is to call the open method, set any custom header information through the setRequestHeader method followed by the send method, and then to check one of the four different response properties.

The XMLHTTP object is supported in Microsoft Internet Explorer (IE) 5.0 or later, as long as your browser settings specify at least one language for use when Web pages are viewed. For more information, see the topic entitled "To specify another language for Web page content" in Internet Explorer Help.

Implemented in: MSXML 3.0 and later


msxml3.dll, msxml2.lib (MSXML 3.0)

msxml6.dll, msxml6.lib (MSXML 6.0)

Header and IDL files: msxml2.h, msxml2.idl, msxml6.h, msxml6.idl

IXMLHTTPRequest Members

© 2017 Microsoft