I got from a Webservice an XML. I declared it as a \"DOMDocument\". This is my XML. Now I want to read all Attributes named \"ZIP\".
xmlDoc.SelectSingleNode("//Cities/City")
always selects the first node. It cannot magically select the next node every time, it would have to read your mind for that.
Private Sub Workbook_Open()
Dim City As String
Dim xmlUrl As String
Dim xmlDoc As New DOMDocument
Dim n As IXMLDOMNode
Dim i As Long
xmlUrl = "http://localhost:62231/dataHandling.asmx/GetAllCities"
xmlDoc.async = False
If Not xmlDoc.Load(xmlUrl) Then
MsgBox "XML LOAD ERROR"
Else
For Each n In xmlDoc.selectNodes("//Cities/City")
City = n.Attributes.getNamedItem("ZIP").Text
City = City & " " & n.Text
Tabelle2.Cells(i + 3, 1).Value = City
i = i + 1
Next
End If
End Sub