I am new to XML. I use the following function to create an xml file. I want change the code to add some more details to its root element. you can refer to the attached picture for my purpose.
Function fnCreateXmlNew()
Dim objDom As DOMDocument
Dim objRootElem As IXMLDOMElement
Dim objMemberElem As IXMLDOMElement
Dim objMemberRel As IXMLDOMAttribute
Dim objMemberName As IXMLDOMElement
Set objDom = New DOMDocument
objDom.appendChild objDom.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8' standalone=""yes""")
Set objRootElem = objDom.createElement("_XPXML")
objDom.appendChild objRootElem
XMLFileName = "C:\Users\SHIVAMAIN\Documents\xml\TEST.xml"
Set ParentNode = objDom.SelectSingleNode("_XPXML")
Set childNode = objDom.createElement("_FTrans")
ParentNode.appendChild childNode
Set nodeAttribute = objDom.createAttribute("Unit")
nodeAttribute.NodeValue = 2
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("UnitAmount")
nodeAttribute.NodeValue = 525.3
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("RefN")
nodeAttribute.NodeValue = 0
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("Desc")
nodeAttribute.NodeValue = "ÈÇÈÊ ÝÇ˜ÊæÑ ÝÑæÔ1"
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("Cre")
nodeAttribute.NodeValue = 0
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("Deb")
nodeAttribute.NodeValue = 3798385
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("Det2")
nodeAttribute.NodeValue = "16/0002"
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("Det1")
nodeAttribute.NodeValue = "03/0654"
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("Acc")
nodeAttribute.NodeValue = "1/0/01/02"
childNode.setAttributeNode nodeAttribute
Set childNode = objDom.createElement("_FTrans")
ParentNode.appendChild childNode
Set nodeAttribute = objDom.createAttribute("Unit")
nodeAttribute.NodeValue = 2
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("UnitAmount")
nodeAttribute.NodeValue = 54.6
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("RefN")
nodeAttribute.NodeValue = 645000
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("ODesc")
nodeAttribute.NodeValue = 41970130298#
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("Desc")
nodeAttribute.NodeValue = "ÈÇÈÊ ÝÇ˜ÊæÑ ÝÑæÔ"
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("Cre")
nodeAttribute.NodeValue = 352170
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("Deb")
nodeAttribute.NodeValue = 0
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("Det2")
nodeAttribute.NodeValue = "03/0654"
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("Det1")
nodeAttribute.NodeValue = "09/1571"
childNode.setAttributeNode nodeAttribute
Set nodeAttribute = objDom.createAttribute("Acc")
nodeAttribute.NodeValue = "4/0/00/01"
childNode.setAttributeNode nodeAttribute
objDom.Save (XMLFileName)
End Function