|
|
To advertise on these forums, e-mail us. |
|
|
Thread Tools | Search this Thread | Display Modes |
#11
|
|||
|
|||
Here's the code to get more then 1 race on the same sheet, should help you figure out how to get all races in a basic sense. Obviously you can build on this so that it works out how many races for that venue etc etc but this should give you a good starting block to get it all working.
Sub LoadRaceField() Dim xmldoc As MSXML2.DOMDocument Set xmldoc = New MSXML2.DOMDocument xmldoc.async = False xmldoc.Load ("http://tatts.com/pagedata/racing/2014/5/21/SR1.xml") If (xmldoc.parseError.errorCode <> 0) Then MsgBox ("An error has occurred: " & xmldoc.parseError.reason) Else Set runnerList = xmldoc.selectNodes("//Runner") Set oddsList = xmldoc.selectNodes("//WinOdds") Sheet1.Cells.Clear For i = 0 To (runnerList.Length - 1) Set Runner = runnerList.Item(i) Set winodds = oddsList.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") Set runnerOdds = winodds.Attributes.getNamedItem("Odds") If Not runnerNumber Is Nothing Then Sheet1.Cells(i + 1, 1) = runnerNumber.Text End If If Not runnerName Is Nothing Then Sheet1.Cells(i + 1, 2) = runnerName.Text End If If Not runnerWeight Is Nothing Then Sheet1.Cells(i + 1, 3) = runnerWeight.Text End If If Not riderName Is Nothing Then Sheet1.Cells(i + 1, 4) = riderName.Text End If If Not runnerOdds Is Nothing Then Sheet1.Cells(i + 1, 5) = runnerOdds.Text End If Next End If Race2 End Sub Sub Race2() Dim xmldoc As MSXML2.DOMDocument Set xmldoc = New MSXML2.DOMDocument xmldoc.async = False xmldoc.Load ("http://tatts.com/pagedata/racing/2014/5/21/SR2.xml") If (xmldoc.parseError.errorCode <> 0) Then MsgBox ("An error has occurred: " & xmldoc.parseError.reason) Else Set runnerList = xmldoc.selectNodes("//Runner") Set oddsList = xmldoc.selectNodes("//WinOdds") For i = 0 To (runnerList.Length - 1) Set Runner = runnerList.Item(i) Set winodds = oddsList.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") Set runnerOdds = winodds.Attributes.getNamedItem("Odds") If Not runnerNumber Is Nothing Then Sheet1.Cells(i + 25, 1) = runnerNumber.Text End If If Not runnerName Is Nothing Then Sheet1.Cells(i + 25, 2) = runnerName.Text End If If Not runnerWeight Is Nothing Then Sheet1.Cells(i + 25, 3) = runnerWeight.Text End If If Not riderName Is Nothing Then Sheet1.Cells(i + 25, 4) = riderName.Text End If If Not runnerOdds Is Nothing Then Sheet1.Cells(i + 25, 5) = runnerOdds.Text End If Next End If End Sub EDIT: I noticed it seems to load quicker then doing the web queries too, might have to be something I look at using instead. |
Thread Tools | Search this Thread |
Display Modes | |
|
|