|
Function readConfig(byval path, byval nodeName)
Set xmlDoc = Nothing
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
'loadXML
xmlDoc.load(path)
Set root = xmlDoc.documentElement
Set objChildNodes = root.getElementsByTagName(nodeName)'Getting nodes collection
Dim num, res
Set res = CreateObject("scripting.dictionary")'新建字典
num = objChildNodes.length'获取Nodes集合的个数
For i = 0 To (num - 1)'循环为字典赋值
res.Add objChildNodes(i).firstChild.text, objChildNodes(i).lastChild.text
Next
set xmlDoc = Nothing
Set readConfig = res
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
我写的一个读取xml文件的函数,主要功能是读取config.xml文件中的配置信息,从而实现数据的动态配置。你参考下,应该能解决你的疑虑。 |
|