1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| Function Coordinates(file As String)
Set XMLDoc = CreateObject("Microsoft.XMLDOM")
XMLDoc.async = False
XMLDoc.Load "R:\PTV\Mes Tests\Test_Macro\" & file
' ------------------------ Service ----------------------------
xpath = "//Placemark"
Dim xxpath As String: xxpath = "Point/coordinates"
Dim nodeName As String
Dim str_oSubNode As String
Sheets("F2").Cells(1, 5) = "Coordonnées MAPS"
ligne = 2
colone = 5
For Each oNode In XMLDoc.SelectNodes(xpath)
For Each oSubNode In oNode.SelectNodes(xxpath)
str_oSubNode = oSubNode.nodeName
If str_oSubNode = "coordinates" Then
Debug.Print "match nodeName : " & oSubNode.nodeName
Sheets("F2").Cells(ligne, colone) = oSubNode.Text
ligne = ligne + 1
Else
Debug.Print ("--------")
Sheets("F2").Cells(ligne, colone) = "-------"
ligne = ligne + 1
End If
Next
Next
Set XMLDoc = Nothing
End Function |
Partager