''读取xml文件,返回root节点
Function readXmlFile(ByVal fileName As String) As Object
Dim xmlFile As Object
Dim root As Object
Set xmlFile = CreateObject("MSXml2.DOMDocument")
xmlFile.async = False
xmlFile.Load (fileName) 'XML文件名,带上路径,比如c:\bbb.XML
xmlFile.setProperty "SelectionLanguage", "XPath" '
Set root = xmlFile.DocumentElement
'Set root = xmlFile.getElementsByTagName("TestItem")
Set readXmlFile = root
End Function
这样调用Set nodeStart = readXmlFile(arrFiles(i))
Function readXmlFile(ByVal fileName As String) As Object
Dim xmlFile As Object
Dim root As Object
Set xmlFile = CreateObject("MSXml2.DOMDocument")
xmlFile.async = False
xmlFile.Load (fileName) 'XML文件名,带上路径,比如c:\bbb.XML
xmlFile.setProperty "SelectionLanguage", "XPath" '
Set root = xmlFile.DocumentElement
'Set root = xmlFile.getElementsByTagName("TestItem")
Set readXmlFile = root
End Function
这样调用Set nodeStart = readXmlFile(arrFiles(i))
本文介绍如何使用VBA宏编写代码来读取XML文件,并返回其根节点。通过设置属性和方法,实现对XML文件的有效解析。
483

被折叠的 条评论
为什么被折叠?



