Sub convertxml()
Dim xmldoc As Object, oCreation As Object, Lig&, Racine As Object, tableau As Object, col As Object, cel As Object
Set xmldoc = CreateObject("Microsoft.XMLDOM") 'creation
Set Racine = xmldoc.createelement(ActiveSheet.Name) 'ajout de la racine "kml"
xmldoc.appendchild Racine 'insertion dans le document (append) de kml
Set oCreation = xmldoc.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'") 'creation de l'entete du process
xmldoc.InsertBefore oCreation, xmldoc.ChildNodes.Item(0) 'insertion parametre process
Set tableau = xmldoc.createelement("Tableau3") 'ajout de la racine "kml"
Racine.appendchild tableau
With Feuil1.ListObjects("Tableau3")
With .HeaderRowRange
For c = 1 To .Cells.Count
Set col = xmldoc.createelement(.Cells(c).Value): tableau.appendchild col 'insertion de la balise document dans la balise kml
With Feuil1.ListObjects("Tableau3").DataBodyRange
For Lig = 1 To .Rows.Count
Set cel = xmldoc.createelement(.Cells(Lig, c).Address(0, 0)): cel.Text = .Cells(Lig, c).Text: col.appendchild cel 'insertion de la balise document dans la balise kml
Next
End With
Next
End With
End With
MsgBox Replace(xmldoc.XML, "><", ">" & vbCrLf & "<")
End Sub