Recommended: How to use ASP to restrict access to web pages To use the ServerVariables property of the request object, use it to get the value of the environment variable. The syntax used is: Request.ServerVariables(variable), "variable" represents the name of the environment variable, such as the server host name,
Before this, I wrote two posts about ASP combining XML, introducing the technologies of replacing databases with XML and integrating databases with XML, so that databases are no longer our only choice in some cases. Compared with traditional databases, XML has the following advantages: smaller file size, more flexible data storage, and more convenient file reading and writing (because XML is a text file, it does not require special software production and maintenance), and XML technology is also the general trend of network development (as can be seen from the comprehensive support of .NET for XML). If you are interested, let's write some of our own functions together to read and write XML more conveniently and intuitively.
At first glance, XML and HTML are very similar in formats. Indeed, because they are all derived from SGML, the basic data is also composed of the first tag, the tail tag, the annotation tag and some ordinary text. However, XML is more syntax-specific than HTML. If you are not careful, your XML will make syntax errors, resulting in the inability to read the data. For example, in HTML, it is completely fine to write <a href=../../index.HTML> as <a href=../../index.HTML>, but this is absolutely not possible in XML. XML requires that the attributes marked must be enclosed in single or double quotes. As for how to write a legal XML file, I have said in the first two articles that you can search and take a look, so I won’t write more here. Here is an example of a legal XML file, which is also what we will use next.
============================================================================== songlist.XML
<?XML version=1.0 encoding=gb2312?>
<!-- Comment: Please indicate the author for reposting-->
<Song List>
<Song title=Yesterday time=1:53 Grading=5/>
<Song title=Imagine Time=3:04 Rating=5/>
<Song title=All You Need Is Love Time=3:52 Rating=4/>
<Song>
<Song Title>Come Together</Song Title>
<Time>4:18</Time>
<Level>4</Level>
</song>
<Song singer=John Lennon>
<Song Title>Oh My Love</Song Title>
<Time>2:44</Time>
<Level>5</Level>
</song>
<Last modified person = time =>No content modified <Last modified>
</Song List>
==============================================================================================================
This example should fully demonstrate the more flexible side of XML than database. Although each record stores the three information of a song title, time, and grading, we have multiple storage methods to choose from. We can either put the data in the attributes of the tag or display the data in the next level tag. As in the previous example, there is no problem that the two coexist. At the same time, XML does not specify how many columns your first record has, and the second record must have that column. As for the example above, we can add another song record, specifying only the song title and time without grading. As for the labels of each record (such as songs in 1-5), they can be repeated or different. You see, I added a last modified label that is completely different from the previous one at the end. In short, while XML requires legal syntax, it also gives developers sufficient freedom. In the past, we can put all the things that had to be recorded in a database using several tables. Below, I will demonstrate step by step how to read and write any of them.
First, just like opening a database, we also have to open our XML file. Like this:
Set rootXML = server.CreateObject(MSXML.DOMDocument)
rootXML.load server.MapPath(XML/config.XML)
MSXML.DOMDocument is a standard component of Windows. It is available on every machine, please feel free to use it.
Then, in order to manipulate various data in the file, we create a cursor-like variable root and point it to the root tag of the XML file (that is, <song list>):
Set root = rootXML.documentelement
If we regard the XML document as a tree structure composed of one-level markup, then now our root object represents the document's root markup, that is, the first-level node (in an XML file, the root markup must be unique). So we set up such a root object to more conveniently access the next-level nodes to achieve control over XML.
As for the XML document we used to sample, its root tag is <Song List>, and its next level tag has 6, the first five are named after <Song>, and the last one is <Last Modification>. Although the names are different, they are all of the same nature. We can treat them together as the second level node of this XML tree structure. Since our root object has pointed to the first-level node, OK, now
Let us stand at the first level node to operate the second level node.
For example, we want to get the text content of a marker in the next level node, such as the text without modification in <Last Modification> <Last Modification>. We can do the following:
Share: Reveal the simple way to solve AJAX Chinese garbled code When using AJAX to develop websites, friends often encounter garbled code problems, and it is difficult to find a solution at once. In fact, it is very simple to solve the problem of Chinese garbled by AJAX. 1. Server program: The following is the reference
2 pages in total Previous page 12 Next page