Create a message with ASP XML
Source: www.yesky.com
First, the reader guidelines
The reader guidelines help you master the syndrome of this article. Solve you to see that this article is not suitable for you, give you visual pollution.
If you are writing some programs with ASP XML, or you are learning XML, it is worth seeing.
Read the knowledge required by this article, there is a basic understanding of the ASP, which is basically understanding the XML and DOM. If you don't know, then you can basically grasp the application of ASP XML and DOM through this article, and can write from this article More advanced ASP XML programs.
Second, the basic idea
This article is based on the use of ASP and DOM to read and store XML data, and utilize XML data to store message information, and achieve the functionality of the same withdrawal database stored data.
Third, the advantage of XML message
Maybe you will ask the ASP TXT text to achieve the function that doesn't have a database, it is really possible, and there is a lot of such a message on the Internet, but here I want to tell the superiority of ASP XML.
1, XML ASP is fast than ASP TXT speed. Maybe you also found that when the txt file is very fast, the speed of the message information is large, but the speed is surprisingly slow. This is the weakness of the ASP TXT. Of course, I can't say that ASP XML must be surprising, but it is much better than ASP TXT, of course, as the message information increases the increase of XML text, it is very fast, but it is still better than TXT. Many (this point can be proved from the WAS test), of course, the ASP XML is not a database, because the database is specially optimized, and XML is just plain text, and the ASP is established to read all the XML data. In the memory, if the amount of data is large, it is conceivable that the speed will slow down. Then you will ask if I use the relationship data stock data, when is it to store data with XML? I will mention it here, that is, when the data is more complicated, I use XML data, and it is what you intend to read it in different operating systems. That is XML. If you are a normal data, don't you store data with an XML file when you don't support the database space or if you don't support the database. 2, XML data is easy to readily readily, txt text is more difficult to operate, we must read judgment in one line, and many features can not be real, can only prepare a relatively simple message, and XML data is different. With DOM, you can easily access each node, not TXT's annoying readline () witeline (), we can add to delete a node we are interested in, using ASP or JS or data islands to easily At this point, of course, I will use the ASP to read the XML data for the time of considering compatibility, and use the data island to read node data (because only IE5 or higher is supported by the data island technology) and use ASP. There is no such question because the customer gets the HTML file.
3, XML data boast system nature, as long as we store these data as XML then these data can be identified by the language or system, without doing what changes. TXT obviously does not have these properties. For example, our message information on the Internet can be converted directly into the WAP format display on the phone. Fourth, establish the XML file (list.xml) of the store message information (List.xml) We don't plan to use DTD, because we are our own XML data, so you don't need DTD to verify (if you are interested in this, of course you can Add one this does not affect the operation of the program). Now let's take a look at the basic elements of establishing a message.
0, message ID number - defined as
1. Username We - Defined as
2, from there - defined as
3, message time - 为
4. User Homepage - 为
5, user's mailbox - defined as
6, message content - 为
Of course, the above is not a must-have to name and add relevant labels, and combine them to get the list of list.xml.
XML Version = "1.0" encoding = "GB2312"?>
Note: You must add eNCoding = "GB2312" otherwise error is an illegal character, because XML does not support Chinese by default.
V. Establish an ASP file (INDEX.ASP) that display XML data
The functionality to be implemented is to read and display XML data, first create an XML object and read XML into the memory, and use DOM to separate the data we want.
<% Strsourcefile = server.mappath ("/") & "/list.xml" Gets the path to the XML file here, according to your virtual directory, different set objXml = server.createObject ("Microsoft.FreethreadedEdxmldom) 'is free Thread Create an XML ObjXML.Load (strsourceFile) 'Read XML file into memory set objrootsite = objxml.documentelement.selectsinglenode ("newlist")' Select NewList node%>