复制代码 代码如下: 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")