Smartgambler
Pro-Punter

Go Back   OZmium Sports Betting and Horse Racing Forums > Public Forums > General Topics
User Name
Password
Register FAQ Search Today's Posts Mark all topics as read

To advertise on these
forums, e-mail us.

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11  
Old 21st May 2014, 04:12 PM
evajb001 evajb001 is offline
Member
 
Join Date: Oct 2009
Posts: 463
Default

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.
Reply With Quote
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Forum Jump



All times are GMT +10. The time now is 04:13 PM.


Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
©2008 OZmium Pty. Ltd. All rights reserved . ACN 091184655