XML-related technical materials summary

Source: Internet
Author: User
Tags xml parser
XML-related technical materials xmlHTTP technology:
----------------------------------------------------------
I. Remote Database Management Technology

Remote Database monitoring is an important part of modern Internet-based WAN applications. First, let's briefly review the development process and methods of the remote database management technology on the Internet:

Early database remote management by writing CGI-BIN module. But the CGI-BIN running speed is slow, maintenance is inconvenient, and now has been basically abandoned.

Over the past few years, there have been a lot of applications using the Component Object Model (COM), and the results are also very good. However, if a third-party server is used (the author's website is built on a third-party virtual host), the server often does not allow users to register their own components for confidentiality or other commercial reasons.

In recent years, Microsoft launched the. NET platform and SUN's J2EE platform are both very high-end remote database management and service platforms. It can provide excellent multi-Tier (n-Tier) application services.
Where ,. NET Simple Object Access Protocol (SOAP) uses Hypertext Transfer Protocol (HTTP) and Extensible Markup Language (XML) cross-system (such as Windows-Linux) communication service methods have been widely accepted and used by developers. Many large applications, such as Enterprise resource planning (ERP), are built on such a large platform.
However, for small and medium-sized applications, such as the construction and maintenance of a website, such a large application platform seems to be too costly.

Microsoft, once lagging behind in Internet technology and Java technology, is ahead in XML application development. The XMLHTTP protocol in her XML parser (MSXML) is a very convenient and practical client/service communication pipeline. The combined use of XMLHTTP and ActiveX Data Objects (ActiveX Data Objects, ADO/ADOX) can easily achieve remote database management.

This article describes how to use XMLHTTP and ADO/ADOX for remote database management.

2. database remote management system

The task process of remote database management is as follows:
1. the client sends a command to the server to query or modify the database structure and data.
2. the server accepts and executes the relevant commands and returns the results to the client.
3. the client accepts and displays the command execution result returned by the server.

Two key steps for achieving remote database management are:
1. the data channel for command upload and result transfer between the client and the server is implemented by XMLHTTP.
2. the command transmission and result return between the server and the database are completed by the ADO/ADOX interface serving as the middle layer.
III. Use of XMLHTTP

As the name implies, XMLHTTP is a hypertext transfer protocol for transmitting XML data.

In fact, the data transmission process of XMLHTTP is more flexible:
It can upload instructions in XML format, strings, streams, or an unsigned integer array. It can also be a URL parameter.
The output result can be XML data, a string, a stream, or an unsigned integer array.
For more information, see the link at the end of the article.

The client calls XMLHTTP in five steps:
1. create an XMLHTTP object
2. open the connection with the server, and define the command sending method, service webpage (URL), and request permissions.
The client opens a connection to the service webpage of the server through the Open command. Like normal HTTP command transmission, you can use the "GET" method or "POST" method to direct to the service webpage of the server.
3. send commands.
4. wait for and receive the processing results returned by the server.
5. release the XMLHTTP object

XMLHTTP method:
Open bstrMethod, bstrUrl, varAsync, bstrUser, bstrPassword
BstrMethod: data transmission method, that is, GET or POST.
BstrUrl: The URL of the service webpage.
VarAsync: whether to run the command synchronously. The default value is True, that is, synchronous execution, but can only be performed in the DOM.
In applications, set it to False, that is, asynchronous execution.
BstrUser: user name, which can be omitted.
BstrPassword: user password, which can be omitted.

Send varBody
VarBody: instruction set. It can be XML data, a string, a stream, or an unsigned integer array. It can also be omitted, so that the command can be substituted by the URL parameter of the Open method.

SetRequestHeader bstrHeader, bstrValue
BstrHeader: HTTP header)
BstrValue: HTTP header value
If the Open method is defined as POST, you can define form upload:
Xmlhttp. setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

XMLHTTP attributes:
Onreadystatechange: obtains the event handle of the returned result in synchronous execution mode. It can only be called in the DOM.
ResponseBody: returns an unsigned integer array.
ResponseStream: the returned result is an IStream stream.
ResponseText: returns a string.
ResponseXML: the returned result is in XML format.


The following is an example of an application in the source program appended to this article:
Function GetResult (urlStr)
Dim xmlHttp
Dim retStr

Set xmlHttp = CreateObject ("Msxml2.XMLHTTP") 'create an object
On Error Resume Next 'Error handling
XmlHttp. Open "POST", urlStr, false' Open the connection in POST mode and execute it asynchronously.
XmlHttp. setRequestHeader "Content-Type", "application/x-www-form-urlencoded" 'Upload form
XmlHttp. send' Send command

If Err. Number = 0 then', If the connection is correct
RetStr = xmlHttp. responseText 'Wait and get the result string returned by the server
Else
RetStr = "Url not found" 'otherwise, an error message is returned.
End If
Set xmlHttp = nothing 'release the object
GetResult = retStr 'return result
End Function

The GetResult () function brings the URL parameter of a service webpage and places the upload command on the parameter following the URL, for example:
UrlStr = "server. asp? Cmd = "& cmd &" & db = "& db &" table = "& table
Cmd: execution method, such as query, modification, and deletion.
Db: name of the server database
Table: The name of the server table.

Then, submit the command and wait for and receive the returned processing result. The result is returned as a string.

Finally, the function caller processes and displays the result.

The above is a summary of XML-related technical materials. For more information, see other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.