TJLD22
TJLD22

Reputation: 145

excel macro: one xml file two root nodes

Now, i'm writing a script to generate xml file by vba macro. I have already creat a root node by following method

Dim xmlDoc As DOMDocument
Dim xmlNode(100) As IXMLDOMElement

Dim rootNodeName_1 As String
rootNodeName_1 = "table" 

Set xmlDoc = New DOMDocument
Set rootNode_1 = xmlDoc.createElement(rootNodeName_1)
Set xmlDoc.DocumentElement = rootNode_1
Set Root_1 = xmlDoc.DocumentElement
Set xmlNode(1) = Root_1

My question is that can I creat another root node under same xmlDoc?

I tried to append another root_2 by same method, but it will cover the previous root_1.

Upvotes: 1

Views: 425

Answers (1)

Omnikrys
Omnikrys

Reputation: 2558

There can only be one root element in an XML document.

Upvotes: 2

Related Questions