Sub proov1() Dim xmlDoc As New MSXML2.DOMDocument Set juur = xmlDoc.createElement("inimene") xmlDoc.appendChild juur Set eesnimi = xmlDoc.createElement("eesnimi") eesnimi.Text = "Juku" juur.appendChild eesnimi MsgBox xmlDoc.XML End Sub Sub proov1() Dim xmlDoc As New MSXML2.DOMDocument Set juur = xmlDoc.createElement("inimene") xmlDoc.appendChild juur Set eesnimi = xmlDoc.createElement("eesnimi") eesnimi.Text = "Juku" juur.appendChild eesnimi MsgBox xmlDoc.XML 'xmlDoc.Save "c:\inimene.xml" Open "c:\inimene.xml" For Output As #1 Print #1, "" Print #1, xmlDoc.XML Close #1 End Sub Sub kirjutaLapsed(doc As MSXML2.DOMDocument60, isikukoht As IXMLDOMElement, lahter As Range) Dim alapiir As Integer Dim lapserida As Integer Dim elem As IXMLDOMElement If Sheet1.UsedRange.Columns.Count > lahter.Column Then alapiir = lahter.Row If Len(Sheet1.Cells(lahter.Row + 1, lahter.Column).Text) = 0 Then alapiir = lahter.Row + 1 Do While (alapiir < Sheet1.UsedRange.Rows.Count) And Len(Sheet1.Cells(alapiir + 1, lahter.Column).Text) = 0 alapiir = alapiir + 1 Loop End If lapserida = lahter.Row + 1 Do While lapserida <= alapiir If Len(Sheet1.Cells(lapserida, lahter.Column + 1)) > 0 Then Set elem = doc.createElement("inimene") elem.Text = Sheet1.Cells(lapserida, lahter.Column + 1).Text isikukoht.appendChild elem kirjutaLapsed doc, elem, Sheet1.Cells(lapserida, lahter.Column + 1) End If lapserida = lapserida + 1 Loop End If End Sub Sub sugupuukirjutus() Dim xmlDoc As New MSXML2.DOMDocument60 Dim alglahter As Range Dim elem As IXMLDOMElement Set alglahter = Sheet1.Cells(1, 1) Set elem = xmlDoc.createElement("inimene") elem.Text = alglahter.Text xmlDoc.appendChild elem kirjutaLapsed xmlDoc, elem, alglahter 'MsgBox xmlDoc.XML Open "c:\sugupuu.xml" For Output As #1 Print #1, "" Print #1, xmlDoc.XML Close #1 End Sub