Sub Process_Globals
Type Row (Description As String, Location As String)
Private Rows As List
Private tempRow As Row
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
Download
End Sub
Sub Download
Dim j As HttpJob
j.Initialize("j", Me)
j.Download("https://www.tulsapolice.org/live-calls-/police-calls-near-you.aspx")
End Sub
Sub JobDone(job As HttpJob)
If job.Success Then
Dim jtidy As Tidy
jtidy.Initialize
'convert html to xml
jtidy.Parse(job.GetInputStream, File.DirInternalCache, "1.html")
Dim sax As SaxParser
sax.Initialize
Dim In As InputStream = File.OpenInput(File.DirInternalCache, "1.html")
Rows.Initialize
tempRow.Initialize
sax.Parse(In, "sax")
In.Close
Log(Rows)
Else
ToastMessageShow("Error downloading page.", True)
Log(job.ErrorMessage)
End If
job.Release
End Sub
Sub Sax_EndElement (Uri As String, Name As String, Text As StringBuilder)
If Name = "td" Then
If tempRow.Description = "" Then
tempRow.Description = Text
Else
tempRow.Location = Text
Rows.Add(tempRow)
Dim tempRow As Row 'create a new object
tempRow.Initialize
End If
End If
End Sub