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):
So any suggestions on how to create the declaration line?
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?