您现在的位置是:网站首页> 编程资料编程资料
vbscript 读取xml格式的配置文件_vbs_
2023-05-25
366人已围观
简介 vbscript 读取xml格式的配置文件_vbs_
复制代码 代码如下:
Class clsGetProfile
' ルートドキュメント
Private rootDoc
' xmlファイル名とセクション名をセットする
' 引数: 「1」ファイル名 NOT NULL
' 戻り値:なし
Public Sub setProfile(strFileName)
Set data_xml = CreateObject("Microsoft.XMLDOM")
data_xml.async = False
data_xml.load(strFileName)
Set rootDoc = data_xml.documentElement
End Sub
' キーの対応する値を取得する
' 引数: 「1」キー名 NOT NULL
' 「2」セクション名 NOT NULL
' 戻り値:キーの対応する値
Public Function getItem(strSectionName, itemName)
Set sectionNode = rootDoc.selectSingleNode(strSectionName)
getItem = sectionNode.selectSingleNode(itemName).attributes(0).nodeValue
End Function
End Class
' 使用サンプル
' クラスインスタンスを生成する
'Dim config : Set config = New clsGetProfile
' 配置ファイル名とセクション名をセットする
'Call config.setProfile("Config.xml")
' きーの対応する値をゲットする
'WScript.Echo config.getItem("MessageDefine", "INFO.001")
'WScript.Echo config.getItem("MessageDefine", "INFO.003")
'WScript.Echo config.getItem("MessageDefine", "ERROR.009")
'WScript.Echo config.getItem("MessageDefine", "ERROR.012")
Class clsGetProfile
' ルートドキュメント
Private rootDoc
' xmlファイル名とセクション名をセットする
' 引数: 「1」ファイル名 NOT NULL
' 戻り値:なし
Public Sub setProfile(strFileName)
Set data_xml = CreateObject("Microsoft.XMLDOM")
data_xml.async = False
data_xml.load(strFileName)
Set rootDoc = data_xml.documentElement
End Sub
' キーの対応する値を取得する
' 引数: 「1」キー名 NOT NULL
' 「2」セクション名 NOT NULL
' 戻り値:キーの対応する値
Public Function getItem(strSectionName, itemName)
Set sectionNode = rootDoc.selectSingleNode(strSectionName)
getItem = sectionNode.selectSingleNode(itemName).attributes(0).nodeValue
End Function
End Class
' 使用サンプル
' クラスインスタンスを生成する
'Dim config : Set config = New clsGetProfile
' 配置ファイル名とセクション名をセットする
'Call config.setProfile("Config.xml")
' きーの対応する値をゲットする
'WScript.Echo config.getItem("MessageDefine", "INFO.001")
'WScript.Echo config.getItem("MessageDefine", "INFO.003")
'WScript.Echo config.getItem("MessageDefine", "ERROR.009")
'WScript.Echo config.getItem("MessageDefine", "ERROR.012")
配置文件格式:
复制代码 代码如下:
相关内容
- vbscript include的办法实现代码第1/2页_vbs_
- vbScript on error resume next容错使用心得_vbs_
- CMD和vbs修改 IP地址及DNS的实现代码_vbs_
- 可自删除 开启3389创建用户粘滞键后门的vbs_vbs_
- 网马生成器 MS Internet Explorer XML Parsing Buffer Overflow Exploit (vista) 0day_vbs_
- vbscript LoadPicture函数使用方法与漏洞利用_vbs_
- IE浏览器增加“复制图像地址”的右键菜单的vbs代码_vbs_
- VBScript 作用 简单说明_vbs_
- ie7 0day当中的shellcode的escape+xor21加密_vbs_
- 利用wsc制作的一个asp后门_vbs_
