#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim URL As String = "http://88.165.185.210:8010/status.xml"
Dim Job1 As HttpJob
Dim inString As String
Dim myParser As SaxParser
Dim ListView1 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("LV1")
Activity.Title = "WebXML"
Job1.Initialize("Job1", Me)
myParser.Initialize
GoGetEm
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub GoGetEm
ProgressDialogShow("Fetching status.xml" )
Job1.Download(URL)
End Sub
Sub Button1_Click 'Refresh
GoGetEm
End Sub
Sub inParsing_EndElement (Uri As String, Name As String, Text As StringBuilder)
If myParser.Parents.IndexOf("response") > -1 Then
If Name.StartsWith("led") Then
ListView1.AddSingleLine2(Name & " = " & Text, Text)
Log(Uri & " : " & Name & " : " & Text)
End If
End If
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "Job1"
'print the result to the logs
inString = Job.GetString
Log(inString)
myParser.Parse(Job.GetInputStream, "inParsing")
End Select
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
ProgressDialogHide
End Sub