Instance Walkthrough Asp+xml Programming (1)

Source: Internet
Author: User
Tags format naming convention xsl
This article is an example to explain the article. As an ordinary programmer, I am well aware that an excellent routine is very helpful to those who are learning to program. The routines used in this article are a contact information management program that I also write to make it easy for me to connect with my friends. But though small, spite, believe to be learning Asp+xml programming friends, or have a certain reference value.

Readers can use this example to learn how to manipulate XML files in an ASP (Active Server Page) and perform various processing of data, including building, modifying, deleting, and saving XML nodes, and so on. The techniques involved include asp,vbscript,dom,xml and XSL.

This article does not carry on the in-depth theory introduction to the use technology, therefore, the reader needs to have certain relevant knowledge, especially to ASP, XML and Dom should have certain understanding. Read through this article, and refer to the source code, I believe that the reader must be proficient in mastering XML programming.


1, program description

The sample is based on the B/s structure, uses an XML file to store contact information, and then uses the DOM to perform various operations on the contact information in the XML file, using a class written in VBScript. The code provided by the

£ º uses a uniform naming convention, which mainly includes: a three-letter abbreviation for variable types, such as numeric type--int, String type--str, Object--obj, and so on, although in Asp/vbscript, the data type is not distinguished, However, using the obvious data type description, the programming and maintenance of the program is still very meaningful; Use meaningful variable names, such as XmlDocument objects, defined as objXMLDoc, and so on, as well as doing so to better write and maintain programs.

The program can be divided into two parts: Background data processing and front interface performance.

In the background of the program, a class is written in VBScript, which is a new feature provided in the VBScript5.0 version. Although the concept of class here and the real object-oriented, but the rational use of class in the ASP, or to a certain extent to improve the operation of the program efficiency and maintainability. The foreground performance of

, using XSL to format data in an XML file, and then exporting it to the client in HTML, fully embodies the flexibility and customization that XML technology offers. The format of the process is placed on the server side, using an ASP program to complete, so that the client is the formatted HTML information to avoid the emergence of compatibility issues.

The program, of course, is not rigorously tested for specific operational details, such as inspection of contact information required, but the program provides complete sample code for the relevant part of using DOM to manipulate XML in ASP.



2. XML Document Description (Persons.xml)

The XML file structure used in this routine is very simple and does not have a schema or DTD defined, because it is unnecessary for this program. Of course, if the reader is willing to define one of its own, it will not affect the operation of the program.

The data structure of the program is defined as follows, the persons collection, which contains multiple person objects, each of whom includes name name, English Nick, mobile phone, telephone tel, email email, Tencent QQ, and the company's properties. The above definition corresponds to an XML file that is, persons is the root node, and person is the child of the persons, Name, Nick, Mobile, Tel, Email, QQ, and company are child nodes of person.

Thus, the contents of the XML file we get are as follows:


 this line, XML does not support Chinese by default, and you can make XML display Chinese correctly by setting the Encoding property. Readers can access this file in IE5.0 and above browsers, and it will display the data in a tree-shaped structure.





Related Article

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.