IXMLDOMDocument删除所有节点或删除完整内容 - VBA Excel

时间:2011-03-24 20:21:53

标签: xml dom vba

以下代码到目前为止工作正常。但现在我想分别映射XML数据,加载后直接映射。 (我想实现进度条......)。出于这个原因,我需要在每个循环中都有一个干净的DOMDocument。我怎么能得到它?

Dim xmldoc As New DOMDocument
Dim xmldata As New DOMDocument
Dim map As xmlMap

Set map = sheet.xmlRelation

For Each fil In fol.Files
    If fil.name Like "*.xml" Then
        xmldoc.Load (fil)
        sheet.transformXml xmldoc
        xmldata.documentElement.appendChild xmldoc.documentElement
    End If
Next fil

map.ImportXML xmldatadata.XML

1 个答案:

答案 0 :(得分:1)

猜猜你想做什么:也许你可以澄清

Dim xmldoc As New DOMDocument
Dim xmldata As DOMDocument
Dim map As xmlMap

Set map = sheet.xmlRelation

For Each fil In fol.Files
     If fil.name Like "*.xml" Then
         xmldoc.Load (fil)
         sheet.transformXml xmldoc
         set xmldata = New DOMDocument
         xmldata.documentElement.appendChild xmldoc.documentElement
         map.ImportXML xmldatadata.XML 
     End If
 Next fil