Add a registry to a Web site "Implementation of the Class"

Source: Internet
Author: User
Registry <%


'------------------------------------------------------------------------------------


' class name: Registryobject Web Information Registry class


' Author: Zhang Shaoji (Tonton)


' e-mail: tonton@yeah.net


' time: August 1, 2004


' Description: To imitate the registry in Windows, combined with XML and ASP technology, to the site to add a dedicated "registry" class.


' URL: http://blog.csdn.net/tonton/archive/2004/08/01/58198.aspx


' Copyright: readers can use this program for any purpose, such as to publish, reprint, please retain the above copyright information!


'------------------------------------------------------------------------------------





Const node_element = 1


Const node_text = 3





Class Registryobject





Private mdom





Public Path Registry path


public Encoding ' registry encoding


public defaultvalue ' the default value that is returned if a subkey does not exist when reading a key value





Private Sub class_initialize ()


defaultvalue = Empty


Encoding = "gb2312"


Set mdom = Nothing


End Sub





Private Sub class_terminate ()


Set mdom = Nothing


End Sub





public Function newdom ()


Set newdom = Server.CreateObject ("Microsoft.XMLDOM")


End Function





Private Property Get Dom ()


Dim Nde


If mdom is nothing Then


Set mdom = newdom ()


Mdom.async = False


mdom.load Path





If mDom.parseError.errorCode = &h800c0006 Then ' File not found


Initial


ElseIf mdom.parseerror <> 0 Then


Exit Property


End If


End If





Set Dom = Mdom


End Property





public Function Initial ()


Dim Nde


Set mdom = newdom ()


with Mdom


Set Nde =. Createprocessinginstruction ("xml", "version= ' 1.0 ' encoding= '" & Encoding & "")


. appendchild (Nde)


Set Nde =. createelement ("Registry")


. appendchild (Nde)


End With


Mdom.save Path


End Function





public Function CreateChannel (Channel)


with Dom


Set CreateChannel =. selectSingleNode ("//" & Channel)


If CreateChannel is nothing Then


Set CreateChannel =. CreateNode (node_element, Channel, "")


. Documentelement.appendchild (CreateChannel)


. Save Path


End If


End With


End Function





public Function getallchannels ()


Dim Result


Dim Nde, I


with Dom


with. Documentelement.childnodes


If. length = 0 Then


result = Split ("", 0)


Else


ReDim result (. length-1)


for i = 0 to. length-1


result (i) =. Item (i). NodeName


Next


End If


End With


End With


Getallchannels = result


End Function





public Function Deletechannel (Channel)


Dim Selection


with Dom


Set Selection =. selectnodes ("//" & Channel)


Selection.removeall


. Save Path


End With


End Function





public Function createsection (Channel, section)


Dim Nde


with Dom


Set Nde =. selectSingleNode ("//" & Channel & "/" & section)


If Nde is nothing Then


Set Nde =. selectSingleNode ("//" & Channel)


If Nde is nothing Then


Set Nde =. CreateNode (node_element, Channel, "")


. Documentelement.appendchild (Nde)


End If





Set createsection =. CreateNode (node_element, section, "")


nde.appendchild (createsection)





. Save Path


End If


End With


End Function





public Function getallsections (Channel)


Dim Result


Dim Nde, I


with Dom


Set Nde =. selectSingleNode ("//" & Channel)


If not Nde be nothing Then


with Nde.childnodes


If. length = 0 Then








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.