Save the following as app. XML, which is in the same directory as the ASP file!
CopyCode The Code is as follows: <? XML version = "1.0" encoding = "UTF-8"?>
<Root>
<About>
<Version> 1.0 Beta </version>
<Latestversion> 1.0 Beta </latestversion>
<Author> author </author>
<Pubdate> 2010/02/20 </pubdate>
</About>
<Config>
<Installed> false </installed>
<Bakpath> _ DATA </bakpath>
</Config>
</Root>
The following are ASP classes and usage methods. Save them as test. asp and run the test. Copy code The Code is as follows: <%
Class appconfig
Dim xmldom
Private sub class_initialize ()
Set xmldom = server. Createobject ("Microsoft. xmldom ")
Xmldom. Load (server. mappath ("app. xml "))
End sub
Private sub class_terminate ()
Set xmldom = nothing
End sub
Function getd (key)
Getd = xmldom. getelementsbytagname (key) (0). Text
End Function
Function setd (Key, Val)
Xmldom. getelementsbytagname (key) (0). Text = Val
Xmldom. Save (server. mappath ("app. xml "))
End Function
Function addd (node, key, Val)
Set newnode = xmldom. getelementsbytagname (node) (0). appendchild (xmldom. createelement (key ))
Newnode. Text = Val
Set newnode = nothing
Xmldom. Save (server. mappath ("app. xml "))
End Function
Function deld (key)
On Error resume next
Xmldom. getelementsbytagname (key) (0). parentnode. removechild (xmldom. getelementsbytagname (key) (0 ))
Xmldom. Save (server. mappath ("app. xml "))
End Function
End Class
Set Config = new appconfig
Wn config. getd ("version ")
Wn config. getd ("latestversion ")
Wn config. getd ("author ")
Wn config. getd ("pubdate ")
Wn config. getd ("installed ")
Wn config. getd ("bakpath ")
'Remove the corresponding annotator to see the [Add/edit/delete] node Effect
'Call config. addd ("Config", "test", "test") 'to add a node
'Call config. setd ("test", "Test2") 'edit a node
'Call config. deld ("test") 'deletes a node.
Sub Wn (STR)
Response. Write (STR) & "<br/>" & vbcrlf
End sub
%>
Not a good choice, but in some cases it is enough to add, delete, or modify nodes.