The following is saved into App.xml, with ASP files in the same directory!
Copy Code code 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 is the ASP class and use method, please save into test.asp, test run
Copy Code code 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 annotation character to see the effect of the Add/edit/delete node
' Call CONFIG.ADDD (' Config ', ' Test ', ' test ') ' Add node
' Call config.setd (' Test ', ' test2 ') ' Edit node
' Call Config.deld (' test ') ' Delete node
Sub WN (str)
Response.Write (str) & "<br/>" &vbcrlf
End Sub
%>
Not a very take-all, but in some cases the use of enough, basically can add/delete/modify Nodes