Instance drill ASP + XML programming

zhaozj2021-02-16  61

This article is an article explained by an instance. As a normal programmer, I know how helpful for people who are learning programming. The routines used in this article are a contact information management program, and I am also written to facilitate myself to contact each other. However, the sparrow is small, the farther is full, and it is believed that friends who are learning ASP XML programming are still having a certain reference value.

Readers can learn how to manipulate the XML file in ASP (Active Server Page), and perform various processing, modification, deletion, and saving of XML nodes, etc. in ASP (Active Server Page). The techniques involved in the text include ASP, VBScript, DOM, XML, and XSL.

This article did not introduce the technology used in the use of the technology, and therefore, readers need certain knowledge, especially for ASP, XML, and DOM. Read this article and refer to the source code, I believe that the reader must master XML programming.

First, the program description   routine Based on the B / S structure, the contact information is stored using the XML file, and then the contact information in the XML file is used in the XML file with the XML file. The code provided by the routine uses a unified naming specification, including: Use three letters of abbreviation, variable type, such as digital type --int, string type - Str, object --Obj, etc., though In ASP / VBScript, do not distinguish between data type, but use obvious data type description, it is also very meaningful to write and maintenance of the program; use meaningful variable names, such as xmlDocument objects, defined as objxmldoc, etc. This is also done to better write and maintain procedures. This procedure can be divided into two parts of the background data processing and the front desk interface. The program is written, and a Class is written using VBScript, which is the new feature provided in the VBScript version 5.0. Although the concept of Class here and the true object-oriented are far from, using Class in ASP, uses Class, or can improve the operational efficiency and maintainability of the program to a certain extent. The front performance, formatted the data in the XML file using XSL, then outputs to the client in HTML, fully reflecting the flexibility and customability of XML technology. The formatted process is placed on the server side. This is done using the ASP program so that the client is formatted after HTML information, avoiding the appearance of compatibility issues. Of course, the procedure is not a very stringent test for specific operation details, such as the check of the information necessary, but for the relevant part of the DOM operation XML in the ASP, the program provides a complete sample code.

Second, XML file instructions (Persons.xml) The XML file structure used in routines is very simple, and there is no defined Schema or DTD because it is unnecessary to this program. Of course, if the reader is willing to define one of them, it will not affect the operation of the program. The data structure of the program is as follows, the Persons collection, which contains multiple Person objects, each of the Person objects, including NAME, English name Nick, mobile phone mobile, phone tel, email email, Tencent QQ and the company company company company company company company The above definitions correspond to the XML file, and Persons are root nodes, Person's child nodes, Name, Nick, Mobile, Tel, Email, QQ, and Company for Person are Person's child nodes. In this way, the XML files we have received are as follows:                                  NAME> GWD 139xxxxxxxx xxxxxxxx                 gwd@chinaren.com     q q 7 7066015

Readers need to pay attention to This line, XML does not support Chinese by default, by setting an Encoding property, the XML can be displayed correctly in Chinese. Readers can access this file in IE5.0 and above browsers, which will display data in a tree structure.

Third, the format conversion XSL file description (PERSONS.XSL) is formatted using XSL data using XSL data and returns to the client in HTML. This process can also be placed on the client, but considering compatibility issues, the routine uses a method of formatting the server end through the ASP manipulation DOM. The content of the             