Sub Class_Globals
Dim Parser As SaxParser
Dim hc As HttpClient
Dim req As HttpRequest
' arraylist
Dim xCategory As List
Dim xDenominazione As List
Dim xIndirizzo As List
Dim xCAP As List
Dim xComune As List
Dim xTelefono As List
Dim xMail As List
Dim xUrl As List
Dim xRecord As List
End Sub
Public Sub Initialize()
xCategory.Initialize
xDenominazione.Initialize
xIndirizzo.Initialize
xCAP.Initialize
xComune.Initialize
xTelefono.Initialize
xMail.Initialize
xUrl.Initialize
xRecord.Initialize
Parser.Initialize
If File.Exists(File.DirRootExternal & "/mimmsos", "Servicelist.xml") = True Then
Dim In As InputStream
In = File.OpenInput(File.DirRootExternal & "/mimmsos", "Servicelist.xml")
Parser.Parse(In, "Parser")
In.Close
Else
hc.Initialize("hc")
End If
End Sub
Public Sub UpdateList(url As String)
If url = "" Then url = "http://www.ivanomonti.eu/ExtraSite/A2013_Clienti/MIMMSOS/servicelist.xml"
req.InitializeGet(url)
hc.Execute(req,1)
End Sub
#Region struttura dati xml
'<?xml version="1.0" encoding="UTF-8"?>
'<dataroot generated="2012-10-04 00:00:00">
' <SERVICELIST>
' <Category>Ricerca e Sviluppo</Category>
' <Denominazione>Senior Developer</Denominazione>
' <Indirizzo>Via del commercio, 2</Indirizzo>
' <CAP>20020</CAP>
' <Comune>Solaro</Comune>
' <Telefono>+393939824007</Telefono>
' <Email>[email protected]</Email>
' <Url>http://www.ivanomonti.eu</Url>
' </SERVICELIST>
'</dataroot>
#End Region
Private Sub hc_ResponseSuccess(Response As HttpResponse, TaskId As Int)
Response.GetAsynchronously("GetXml", File.OpenOutput(File.DirRootExternal & "/mimmsos", "servicelist.xml", False), True, TaskId)
End Sub
Private Sub hc_ResponseError(Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
If Response <> Null Then
Msgbox("Error: " & Response.GetString("UTF8"), "Alert")
Response.Release
End If
End Sub
Public Sub GetXml_StreamFinish(Success As Boolean, TaskId As Int)
If Success = False Then
Msgbox(LastException.Message, "Error")
Return
End If
Try
Dim In As InputStream
In = File.OpenInput(File.DirRootExternal & "/mimmsos", "Servicelist.xml")
Parser.Parse(In, "Parser")
In.Close
' creare azione per popolare view
Catch
Msgbox("Error xml","Alert")
End Try
End Sub
Private Sub Parser_StartElement(Uri As String, Name As String, Attributes As Attributes)
End Sub
Private Sub Parser_EndElement(Uri As String, Name As String, Text As StringBuilder)
If Name = "Category" Then
xCategory.Add(Text.ToString)
Else If Name = "Denominazione" Then
xDenominazione.Add(Text.ToString)
Else If Name = "Indirizzo" Then
xIndirizzo.Add(Text.ToString)
Else If Name = "CAP" Then
xCAP.Add(Text.ToString)
Else If Name = "Comune" Then
xComune.Add(Text.ToString)
Else If Name = "Telefono" Then
xTelefono.Add(Text.ToString)
Else If Name = "Email" Then
xMail.Add(Text.ToString)
Else If Name = "Url" Then
xUrl.Add(Text.ToString)
End If
End Sub