Sub kirjutaXML1() Open "loetelu1.xml" For Output As #1 Print #1, "" Print #1, "" reanr = 1 Do While Len(Cells(reanr, 1)) > 0 Print #1, " " Print #1, " " & Cells(reanr, 1) & _ "" Print #1, " " & Cells(reanr, 2) & _ "" Print #1, " " reanr = reanr + 1 Loop Print #1, "" Close #1 End Sub Sub loeXML1() Set dok = CreateObject("MSXML.DomDocument") dok.Load "loetelu1.xml" MsgBox dok.documentElement.childnodes(0).childnodes(0).Text MsgBox dok.documentElement.childnodes.Length End Sub Sub loeXML2() Set dok = CreateObject("MSXML.DomDocument") dok.Load "loetelu1.xml" 'MsgBox dok.documentElement.childnodes(0).childnodes(0).Text For nr = 1 To dok.documentElement.childnodes.Length Cells(nr, 5) = dok.documentElement.childnodes(nr - 1). _ childnodes(0).Text Cells(nr, 6) = dok.documentElement.childnodes(nr - 1). _ childnodes(1).Text Next nr End Sub Sub loeXML3() Set dok = CreateObject("MSXML.DomDocument") dok.Load "loetelu1.xml" Set inimesed = dok.getElementsByTagName("inimene") reanr = 1 For Each inimene In inimesed Cells(reanr, 5) = inimene.selectSingleNode("eesnimi").Text Cells(reanr, 6) = inimene.selectSingleNode("perekonnanimi").Text reanr = reanr + 1 Next inimene End Sub Sub kirjutaXMLPuu() Set dok = CreateObject("MSXML.DomDocument") Set juur = dok.createNode(1, "inimesed", "") dok.documentElement = juur reanr = 1 Do While Len(Cells(reanr, 1)) > 0 Set inimene = dok.createNode(1, "inimene", "") juur.appendChild inimene Set eesnimi = dok.createNode(1, "eesnimi", "") inimene.appendChild eesnimi eesnimi.Text = Cells(reanr, 1) Set perekonnanimi = dok.createNode(1, "perekonnanimi", "") inimene.appendChild perekonnanimi perekonnanimi.Text = Cells(reanr, 2) reanr = reanr + 1 Loop Open "loetelu2.xml" For Output As #1 Print #1, "" Print #1, dok.xml Close #1 End Sub