ASP Operations XML Refining class, including sample code _asp class classes

Source: Internet
Author: User
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
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.