Detailed explanation of Microsoft's XMLHTTP object
Microsoft.XML
HTTP object is provided in MSXML, which can complete the conversion and sending tasks from data packets to Request objects.
The statements to create an XMLHTTP object are as follows:
Set objXML = CreateObject("Msxml2.XMLHTTP") or
Set objXML = CreateObject("Microsoft.XMLHTTP")
'Or for version 3.0 of
MSXML provides the Microsoft.XMLHTTP object, which can complete the conversion and sending tasks from data packets to Request objects.
The statement to create an XMLHTTP object is as follows:
Set objXML = CreateObject("Msxml2.XMLHTTP") 或 Set objXML = CreateObject("Microsoft.XMLHTTP") 'Or for version 3.0 of XMLHTTP, use:
'Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
After the object is created, call the Open method to initialize the Request object. The syntax format is:
objXML.open http-method,url,async,userID,password
The Open method contains 5 parameters. The first three are necessary, and the last two are optional (provided when server requires authentication). The meaning of the parameters is as follows:
http-method: HTTP communication method, such as GET or POST
url: Server that receives XML data URL address. Usually ASP or CGI program
async should be specified in the URL: A Boolean identifier indicating whether the request is asynchronous. If it is an asynchronous communication mode (true), the client will not wait for the response from the server ; if it is a synchronous mode (false), the client will wait until the server returns the message before executing it. Other operations
userID: User ID, used for server Authentication
password: User password, used for server Authentication
Send method of XMLHTTP object
After initializing the Request object with the Open method, call the Send method to send XML data:
objXML.send()
The parameter type of the Send method is Variant, which can be a string, DOM tree or any data stream.
There are two ways to send data: synchronous and asynchronous. In asynchronous mode, once the data packet is sent, the Send process is ended, and the client performs other operations; in synchronous mode, the client waits until the server returns a confirmation message before ending the Send process.
The readyState attribute in the XMLHTTP object
can reflect the progress of the server in processing the request. The client program can set the corresponding event processing method based on this status information. The attribute values and their meanings are shown in the following table:
Value description
0 The Response object has been created, but the XML document upload process has not yet ended
1 The XML document has been loaded
2 The XML document has been Loading completed and being processed
3 Part of the XML document has been parsed
4 The document has been parsed and the client can accept the return message
The client processes the response information. After the client receives the return message, it performs a simple Processing basically completes an interaction cycle between C/S.
The client receives the response through the properties of the XMLHTTP object:
responseText: Return the message as a text string;
responseBody:Return the message as HTML document Content;
responseXML: Treat the return message as an XML document, used when the server response message contains XML data;
responseStream: Treat the return message as a Stream object
Here is a simple example: Similar to News Thief
<% Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP") objXML.open "GET","http://www.alexa.com",false objXML.send() response.write(objXML.responseText) %>
The whole steps are obvious: create, open, send and receive.
The above is the detailed content of Detailed explanation of Microsoft's XMLHTTP object. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Can XML files be opened with PPT? XML, Extensible Markup Language (Extensible Markup Language), is a universal markup language that is widely used in data exchange and data storage. Compared with HTML, XML is more flexible and can define its own tags and data structures, making the storage and exchange of data more convenient and unified. PPT, or PowerPoint, is a software developed by Microsoft for creating presentations. It provides a comprehensive way of

Understand the meaning of HTTP 301 status code: common application scenarios of web page redirection. With the rapid development of the Internet, people's requirements for web page interaction are becoming higher and higher. In the field of web design, web page redirection is a common and important technology, implemented through the HTTP 301 status code. This article will explore the meaning of HTTP 301 status code and common application scenarios in web page redirection. HTTP301 status code refers to permanent redirect (PermanentRedirect). When the server receives the client's

You can log in with a Microsoft account in the win10 system, but there are still many friends who don’t know how to log in. Today I will bring you the method of logging in with a win10 Microsoft account. Come and take a look. How to log in to win10 microsoft account: 1. Click Start in the lower left corner and click the gear to open settings. 2. Then find "Account" and click to open. 3. After entering the account, click "Email and App Accounts" on the left. 4. Then click "Add Account" on the right. 5. After entering the account interface, many options will appear. Click the first "outlook". 6. Enter your account number in the Microsoft account window that appears. 7. After all is completed, you can

HTTP Status Code 200: Explore the Meaning and Purpose of Successful Responses HTTP status codes are numeric codes used to indicate the status of a server's response. Among them, status code 200 indicates that the request has been successfully processed by the server. This article will explore the specific meaning and use of HTTP status code 200. First, let us understand the classification of HTTP status codes. Status codes are divided into five categories, namely 1xx, 2xx, 3xx, 4xx and 5xx. Among them, 2xx indicates a successful response. And 200 is the most common status code in 2xx

Use PHPXML functions to process XML data: Parse XML data: simplexml_load_file() and simplexml_load_string() load XML files or strings. Access XML data: Use the properties and methods of the SimpleXML object to obtain element names, attribute values, and subelements. Modify XML data: add new elements and attributes using the addChild() and addAttribute() methods. Serialized XML data: The asXML() method converts a SimpleXML object into an XML string. Practical example: parse product feed XML, extract product information, transform and store it into a database.

How to implement HTTP streaming in C++? Create an SSL stream socket using Boost.Asio and the asiohttps client library. Connect to the server and send an HTTP request. Receive HTTP response headers and print them. Receives the HTTP response body and prints it.

The HTTP request times out, and the server often returns the 504GatewayTimeout status code. This status code indicates that when the server executes a request, it still fails to obtain the resources required for the request or complete the processing of the request after a period of time. It is a status code of the 5xx series, which indicates that the server has encountered a temporary problem or overload, resulting in the inability to correctly handle the client's request. In the HTTP protocol, various status codes have specific meanings and uses, and the 504 status code is used to indicate request timeout issues. in customer

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an
