Hi All
I am trying to import data from an XML webpage/file but I cannot seem to get the code quite right to import the desired information. I wonder if anyone would care to take a look please?
The webpage address is
My issue is that I can only get the first line not the remaining 23 contained in the document. The code I have at this stage is:
[pre]Sub LoadRaceDay()
Dim xmldoc As MSXML2.DOMDocument
Set xmldoc = New MSXML2.DOMDocument
xmldoc.async = False
xmldoc.Load ("http://tatts.com/pagedata/racing/2013/4/5/RaceDay.xml"
If (xmldoc.parseError.ErrorCode <> 0) Then
MsgBox ("An error has occurred: " & xmldoc.parseError.reason)
Else
Set RaceDay = xmldoc.SelectNodes("//Meeting"
Sheet1.Cells.Clear
For i = 0 To (RaceDay.Length - 1)
Set RaceDay = RaceDay.Item(i)
Set MeetingCode = RaceDay.Attributes.getNamedItem("MeetingCode"
Set VenueName = RaceDay.Attributes.getNamedItem("VenueName"
Set HiRaceNo = RaceDay.Attributes.getNamedItem("HiRaceNo"
Set MeetingType = RaceDay.Attributes.getNamedItem("MeetingType"
Set Abandoned = RaceDay.Attributes.getNamedItem("Abandoned"
If Not MeetingCode Is Nothing Then
Sheet1.Cells(i + 1, 1) = MeetingCode.Text
End If
If Not VenueName Is Nothing Then
Sheet1.Cells(i + 1, 2) = VenueName.Text
End If
If Not HiRaceNo Is Nothing Then
Sheet1.Cells(i + 1, 3) = HiRaceNo.Text
End If
If Not MeetingType Is Nothing Then
Sheet1.Cells(i + 1, 4) = MeetingType.Text
End If
If Not Abandoned Is Nothing Then
Sheet1.Cells(i + 1, 5) = Abandoned.Text
End If
Next
End If
End Sub[/code][/pre]
Any assistance would be greatly appreciated.
Cheers
Shaun
I am trying to import data from an XML webpage/file but I cannot seem to get the code quite right to import the desired information. I wonder if anyone would care to take a look please?
The webpage address is
Code:
http://tatts.com/pagedata/racing/2013/4/5/RaceDay.xml
The data I am trying to extract is:
- MeetingCode
- HiRaceNo
- SortOrder
- VenueName
- Abandoned
- MeetingType
The line in the xml is:
[code]+<Meeting MeetingCode="BR" HiRaceNo="7" SortOrder="0" VenueName="Doomben" Abandoned="N" MeetingType="R">
My issue is that I can only get the first line not the remaining 23 contained in the document. The code I have at this stage is:
[pre]Sub LoadRaceDay()
Dim xmldoc As MSXML2.DOMDocument
Set xmldoc = New MSXML2.DOMDocument
xmldoc.async = False
xmldoc.Load ("http://tatts.com/pagedata/racing/2013/4/5/RaceDay.xml"
If (xmldoc.parseError.ErrorCode <> 0) Then
MsgBox ("An error has occurred: " & xmldoc.parseError.reason)
Else
Set RaceDay = xmldoc.SelectNodes("//Meeting"
Sheet1.Cells.Clear
For i = 0 To (RaceDay.Length - 1)
Set RaceDay = RaceDay.Item(i)
Set MeetingCode = RaceDay.Attributes.getNamedItem("MeetingCode"
Set VenueName = RaceDay.Attributes.getNamedItem("VenueName"
Set HiRaceNo = RaceDay.Attributes.getNamedItem("HiRaceNo"
Set MeetingType = RaceDay.Attributes.getNamedItem("MeetingType"
Set Abandoned = RaceDay.Attributes.getNamedItem("Abandoned"
If Not MeetingCode Is Nothing Then
Sheet1.Cells(i + 1, 1) = MeetingCode.Text
End If
If Not VenueName Is Nothing Then
Sheet1.Cells(i + 1, 2) = VenueName.Text
End If
If Not HiRaceNo Is Nothing Then
Sheet1.Cells(i + 1, 3) = HiRaceNo.Text
End If
If Not MeetingType Is Nothing Then
Sheet1.Cells(i + 1, 4) = MeetingType.Text
End If
If Not Abandoned Is Nothing Then
Sheet1.Cells(i + 1, 5) = Abandoned.Text
End If
Next
End If
End Sub[/code][/pre]
Any assistance would be greatly appreciated.
Cheers
Shaun