OK, Thanks for that but I still have a problem. I get an error that says Expected 'End' Line 204. I have colored line 204 in red and bold Here is my entire code.
Code:
<%
Function WriteToFile( str_FileName, str_Message )
Set obj_FSO = Server.CreateObject("Scripting.FileSystemObject")
Set obj_OutputFile = obj_FSO.OpenTextFile(str_FileName, 2, True, 0)
obj_OutputFile.WriteLine(str_Message)
obj_OutputFile.Close
Set obj_OutputFile = Nothing
Set obj_FSO = Nothing
End Function
Function GetURL(str_URL)
Set obj_XMLHTTP = Server.CreateObject ("MSXML2.ServerXMLHTTP.3.0")
obj_XMLHTTP.Open "GET", str_URL, False, "", ""
obj_XMLHTTP.Send()
While obj_XMLHTTP.readyState <> 4
obj_XMLHTTP.waitForResponse(8000)
Wend
If Err.Number = 0 Then
' Response.Write("Status = " & obj_XMLHTTP.Status & "<br>")
If obj_XMLHTTP.Status = 200 Then
str_GetURL = obj_XMLHTTP.ResponseText
Else
str_GetURL = "Bad URL"
End If
Else
str_GetURL = "Bad URL"
End If
Set obj_XMLHTTP = Nothing
GetURL = str_GetURL
End Function
%>
<%
str_Response = GetURL("http://livescores.afl.com.au/flash/match-10131201.xml")
If str_Response <> "Bad URL" Then
WriteToFile Server.MapPath("test.xml"), str_Response
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
xml.load (Server.MapPath("test.xml"))
If xml.parseError.errorCode <> 0 Then
Response.Write xml.parseError.reason
End If
mtchstts = xml.documentElement.childNodes(2).Attributes(12).text
mtchbrek = xml.documentElement.childNodes(2).Attributes(14).text
If mtchstts = "P" Then
homegoal = 0
homebehi = 0
awaygoal = 0
awaybehi = 0
Else If mtchstts = "L" Then
quarter1 = xml.documentElement.childNodes(3).childNodes(0).Attributes(6).text
If quarter1 = "N" Then
' The 1st quarter isn't complete
' It is the 1st quarter
quarter = 0
Else If quarter1 = "Y" And mtchbrek = "Y" Then
' The 1st quarter is complete and it's a break
' It is Quarter Time
quarter = 0
Else If quarter1 = "Y" And mtchbrek = "N" Then
' The 1st quarter is complete and it isn't a break
' It is the 2nd quarter
quarter = 1
quarter2 = xml.documentElement.childNodes(3).childNodes(1).Attributes(6).text
Else If quarter2 = "N" Then
' The 2nd quarter isn't complete
' It is the 2nd quarter
quarter = 1
Else If quarter2 = "Y" And mtchbrek = "Y" Then
' The 2nd quarter is complete and it is a break
' It is Half Time
quarter = 1
Else If quarter2 = "Y" And mtchbrek = "N" Then
' The 2nd quarter is complete and it isn't a break
' It is the 3rd quarter
quarter = 2
quarter3 = xml.documentElement.childNodes(3).childNodes(2).Attributes(6).text
Else If quarter3 = "N" Then
' The 3rd quarter isn't complete
' It is the 3rd quarter
quarter = 2
Else If quarter3 = "Y" And mtchbrek = "Y" Then
' The 3rd quarter is complete and it is a break
' It is Three Quarter Time
quarter = 2
Else If quarter3 = "Y" And mtchbrek = "N" Then
' The 3rd quarter is complete and it isn't a break
' It is the 4th quarter
quarter = 3
quarter4 = xml.documentElement.childNodes(3).childNodes(3).Attributes(6).text
Else If quarter4 = "N" Then
' The 4th quarter isn't complete
' It is the 4th quarter
quarter = 3
Else If quarter4 = "Y" Then
' The 4th quarter is complete
' It is Full Time
quarter = 3
End If
End If
homeabbr = xml.documentElement.childNodes(2).Attributes(2).text
homegoal = xml.documentElement.childNodes(3).childNodes(quarter).Attributes(1).text
homebehi = xml.documentElement.childNodes(3).childNodes(quarter).Attributes(2).text
homescor = (homegoal*6) + Int(homebehi)
awayabbr = xml.documentElement.childNodes(2).Attributes(6).text
awaygoal = xml.documentElement.childNodes(3).childNodes(quarter).Attributes(3).text
awaybehi = xml.documentElement.childNodes(3).childNodes(quarter).Attributes(4).text
awayscor = (awaygoal*6) + Int(awaybehi)
Set xml = Nothing
End If
%>
<html>
<head>
<title></title>
</head>
<body bgcolor="#333333">
<div style="position: absolute; top: 2px; left: 2px; width:; width: 950px; height: 72px;">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td bgcolor="#333333">
<%=quarter%>
</td></tr>
<tr>
<td bgcolor="#333333">
<img src="/afl/images/digital/lrg/<%=homeabbr%>.gif">
<img src="/afl/images/digital/lrg/space.gif">
<% if len(homegoal)=1 then %><img src="/afl/images/digital/lrg/space.gif" border="0"> <% end if %>
<% for n = 1 to len(homegoal)
Response.Write "<img src='/afl/images/digital/lrg/" & mid(homegoal,n,1) & ".gif'>"
If n < len(homegoal) Then
Response.Write " "
End If
next %>
<img src="/afl/images/digital/lrg/dot.gif" border="0">
<% if len(homebehi)=1 then %><img src="/afl/images/digital/lrg/space.gif" border="0"> <% end if %>
<% for n = 1 to len(homebehi)
Response.Write "<img src='/afl/images/digital/lrg/" & mid(homebehi,n,1) & ".gif'>"
If n < len(homebehi) Then
Response.Write " "
End If
next %>
<img src="/afl/images/digital/lrg/dot.gif" border="0">
<% if len(homescor)=2 then %><img src="/afl/images/digital/lrg/space.gif" border="0"> <% end if %>
<% if len(homescor)=1 then %><img src="/afl/images/digital/lrg/space.gif" border="0"> <img src="/afl/images/digital/lrg/space.gif" border="0"> <% end if %>
<% for n = 1 to len(homescor)
Response.Write "<img src='/afl/images/digital/lrg/" & mid(homescor,n,1) & ".gif'>"
If n < len(homescor) Then
Response.Write " "
End If
next %>
</td></tr>
<tr>
<td bgcolor="#333333">
<img src="/afl/images/digital/lrg/<%=awayabbr%>.gif">
<img src="/afl/images/digital/lrg/space.gif">
<% if len(awaygoal)=1 then %><img src="/afl/images/digital/lrg/space.gif" border="0"> <% end if %>
<% for n = 1 to len(awaygoal)
Response.Write "<img src='/afl/images/digital/lrg/" & mid(awaygoal,n,1) & ".gif'>"
If n < len(awaygoal) Then
Response.Write " "
End If
next %>
<img src="/afl/images/digital/lrg/dot.gif" border="0">
<% if len(awaybehi)=1 then %><img src="/afl/images/digital/lrg/space.gif" border="0"> <% end if %>
<% for n = 1 to len(awaybehi)
Response.Write "<img src='/afl/images/digital/lrg/" & mid(awaybehi,n,1) & ".gif'>"
If n < len(awaybehi) Then
Response.Write " "
End If
next %>
<img src="/afl/images/digital/lrg/dot.gif" border="0">
<% if len(awayscor)=2 then %><img src="/afl/images/digital/lrg/space.gif" border="0"> <% end if %>
<% if len(awayscor)=1 then %><img src="/afl/images/digital/lrg/space.gif" border="0"> <img src="/afl/images/digital/lrg/space.gif" border="0"> <% end if %>
<% for n = 1 to len(awayscor)
Response.Write "<img src='/afl/images/digital/lrg/" & mid(awayscor,n,1) & ".gif'>"
If n < len(awayscor) Then
Response.Write " "
End If
next %>
</td></tr>
</table>
</div>
</body>
</html>
My aim of the file is to show live scores. Here is another problem that you may find that I tried to fix but I don't know if worked because I am getting the previous problem. Anyway, if you can fix the provious problem maybe you can work out a better way to fix this: When quarter1 = "N" quarter2 doesn't exist. When quarter2 = "N" quarter3 doesn't exist. When quarter3 = "N" quarter4 doesn't exist. When it doesn't exist, I get an error saying that there is an object required (it cant find it in the xml document because it doesn't exist). Is there a way around this problem and how can it be done?
Bookmarks