Sub LoadRaceField()
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:=""
Dim xmldoc As MSXML2.DOMDocument
Set xmldoc = New MSXML2.DOMDocument
xmldoc.async = False
xmldoc.Load ("http://unitab.com/data/racing/" & Format(Range("M4"), "yyyy/m/d") & "/" & Range("M5") & ".xml")
If (xmldoc.parseError.ErrorCode <> 0) Then
MsgBox ("An error has occurred: " & xmldoc.parseError.reason)
Else
Set runnerList = xmldoc.SelectNodes("//Runner")
Sheet3.Cells.Clear
For i = 0 To (runnerList.Length - 1)
Set runner = runnerList.Item(i)
Set runnerNumber = runner.Attributes.getNamedItem("RunnerNo")
Set runnerName = runner.Attributes.getNamedItem("RunnerName")
Set runnerWeight = runner.Attributes.getNamedItem("Weight")
Set riderName = runner.Attributes.getNamedItem("Rider")
If Not runnerNumber Is Nothing Then
Sheet3.Cells(i + 1, 1) = runnerNumber.Text
End If
If Not runnerName Is Nothing Then
Sheet3.Cells(i + 1, 2) = runnerName.Text
End If
If Not runnerWeight Is Nothing Then
Sheet3.Cells(i + 1, 3) = runnerWeight.Text
End If
If Not riderName Is Nothing Then
Sheet3.Cells(i + 1, 4) = riderName.Text
End If
Set winOdds = runner.SelectSingleNode("WinOdds")
Set placeOdds = runner.SelectSingleNode("PlaceOdds")
If Not winOdds Is Nothing Then
Set winOddsAmount = winOdds.Attributes.getNamedItem("Odds")
If Not winOddsAmount Is Nothing Then
Sheet3.Cells(i + 1, 5) = winOddsAmount.Text
End If
End If
If Not placeOdds Is Nothing Then
Set placeOddsAmount = winOdds.Attributes.getNamedItem("Odds")
If Not placeOddsAmount Is Nothing Then
Sheet3.Cells(i + 1, 6) = placeOddsAmount.Text
End If
End If
Next
End If
Range("E28").Select
ActiveSheet.Protect Password:=""
Application.ScreenUpdating = True
End Sub