Create XML Declaration in VBA

buratti

Registered User.
Local time
Today, 00:08
Joined
Jul 8, 2009
Messages
234
I am creating a XML document in VBA using MSXML 6 object library. I have written all the code to create the document, but am missing the declaration line of the document (<?xml version="1.0" encoding="utf-8"?>). How do I enter this line? My code format is as follows (not my actual code, but just the "method" i used to create it):

Code:
Dim xmldoc As DOMDocument
Dim rootElement As IXMLDOMElement
Dim aElement As IXMLDOMElement

 
'Creating DOM Document object
Set xmldoc = New DOMDocument

'Create the root element
Set rootElement = xmldoc.createElement("myRoot")
Set xmldoc.appendchild = rootElement

'Create the node 
Set aElement = xmldoc.createElement("myElement")
'add the student node to the root
rootElement.appendChild aElement

So any suggestions on how to create the declaration line?
 

Users who are viewing this thread

Back
Top Bottom