Opret XML-fil fra VB 6.0
Hej Alle.Jeg er XML begynder, og vil oprette en XML-fil fra VB 6.0
Jeg har problemer med at få det rigtige output
Mit ønske var at det så således ud.
<?xml version="1.0" encoding="UTF-8" ?>
- <Invoice>
<TEST>1234</TEST>
- <Book>
<ID>9999</ID>
<IssueDate>21-11-04</IssueDate>
</Book>
</Invoice>
Men jeg kan ikke få <TEST>1234</TEST> indsat.
Min kode er som nedestående.
_________________________________________________
Dim objXMLDOM As DOMDocument40
Dim Pi As IXMLDOMProcessingInstruction
Dim Invoice As Object
Dim Book As Object
Set objXMLDOM = CreateObject("Microsoft.XMLDOM")
Set Pi = objXMLDOM.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'")
Set objXMLDOM.documentElement = objXMLDOM.createElement("Invoice")
Set Book = objXMLDOM.createElement("Book")
objXMLDOM.insertBefore Pi, objXMLDOM.childNodes.Item(0)
Book.appendChild objXMLDOM.createElement("ID")
Book.appendChild objXMLDOM.createElement("IssueDate")
Book.childNodes(0).Text = "9999" ' Fakturanummer
Book.childNodes(1).Text = "21-11-04" 'Fakturadato
objXMLDOM.documentElement.appendChild Book.cloneNode(True)
objXMLDOM.Save (App.Path & "\myXMLfile1.xml")
Set Pi = Nothing
Set objXMLDOM = Nothing
_________________________________________________
Min XML output er
<?xml version="1.0" encoding="UTF-8" ?>
- <Invoice>
- <Book>
<ID>9999</ID>
<IssueDate>21-11-04</IssueDate>
</Book>
</Invoice>