Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Microsoft.XMLHTTP object

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article shares content about sample parsing of Microsoft.XMLHTTP objects. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

MSXML provides Microsoft.XMLHTTP objects, which can complete the transformation from data packets to Request objects and send tasks. The statement to create an XMLHTTP object is as follows: Set objXML = CreateObject("Msxml2.XMLHTTP") or Set objXML = CreateObject("Microsoft.XMLHTTP")'Or for version 3.0 of

MSXML provides Microsoft.XMLHTTP objects, which can complete the transformation from data packets to Request objects and send tasks.

The statement to create an XMLHTTP object is as follows:

Set objXML = CreateObject("Msxml2.XMLHTTP") or

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 five parameters, the first three are required and the last two are optional (provided when authentication is required on the server). Parameters have the following meanings:

http-method: HTTP communication method, such as GET or POST

url: URL address of the server receiving XML data. Usually ASP or CGI programs are indicated in the URL

async: A Boolean flag indicating whether the request is asynchronous. If asynchronous (true), the client does not wait for a response from the server; if synchronous (false), the client waits until the server returns a message before performing 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:

The parameter type of the objXML.send() Send method is Variant, which can be a string, DOM tree, or arbitrary data stream.

There are two ways to send data: synchronous and asynchronous. In asynchronous mode, once the packet is sent, the Send process ends and the client performs other operations; in synchronous mode, the client waits until the server returns an acknowledgement message before ending the Send process.

ReadyState property in XMLHTTP object

It can reflect the progress of the server in processing the request. The client program can set the event handling method according to this state information. Attribute values and their meanings are shown in the following table:

value description

0 Response object created, but XML document upload process not finished

1 The XML document has been loaded

2 XML document has been loaded and is being processed

3 Some XML documents have been parsed

4 The document has been parsed, and the client can accept the return message.

The client processes the response message, and after receiving the return message, the client performs simple processing, basically completing an interaction cycle between C/S.

The client receives the response via attributes of the XMLHTTP object:

responseText: return message as text string;

responseBody: return message as HTML document content;

responseXML: treats the return message as an XML document, used when the server response message contains XML data;

responseStream: treats the returned message as a Stream object

Here's a simple example: Similar to News Thief

The whole process is obvious: create, open, send and receive.

Thank you for reading! About "Microsoft.XMLHTTP object sample analysis" This article is shared here, I hope the above content can be of some help to everyone, so that we can learn more knowledge, if you think the article is good, you can share it to let more people see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report