Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private Parser As SaxParser
Private DocList As List
Type MyDoc (ID As String, title As String ,Datei As String,Datum As String,Dokumententtyp As String,Sprache As String,Anwendungsbereich As String,Aktualisierungszeitpunkt As String,DtTop As String, Seitenzahl As String, keywords As String, Size As String)
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
LadeXML 'Don't do such heavy process in the Application_Start sub
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
End Sub
Private Sub Application_Background
End Sub
Sub LadeXML()
Dim j As HttpJob
j.Initialize("XML", Me)
j.Download("http://m-te.de/list_klein.xml")
j.GetRequest.Timeout = 600000
End Sub
Private Sub JobDone (Job As HttpJob)
If Job.Success = True Then
CallSubDelayed2(Me,"ParseXML",Job.GetString) 'Why you are using CallSubDelayed here? --> This mistake is actually the reason for the error.
End If
Job.Release
End Sub
Private Sub ParseXML(Key As String)
DocList.Initialize
Dim In As InputStream 'You don't have to create a new InputStream, checkout the Parse2 Method of the parser
Dim data() As Byte = Key.GetBytes("UTF8")
In.InitializeFromBytesArray(data, 0, data.Length)
Parser.Initialize
Parser.Parse(In, "Parser")
Log("End Parse")
End Sub
Private Sub Parser_StartElement (uri As String, Name As String, Attributes As Map)
If Name = "id" Then
Dim Doc As MyDoc
Doc.Initialize
DocList.Add(Name) 'Probably, here you wanted to add your Doc type, and you have forgotten Doc.ID = Name, right?
End If
End Sub
Private Sub Parser_EndElement (uri As String, Name As String, Text As StringBuilder)
If Parser.Parents.IndexOf("Download") > -1 Then
Dim Doc As MyDoc
Doc = DocList.Get(DocList.Size - 1) 'ref to the last Doc 'The last element in you List is a String type and not a Doc type
Log(Name)
Select Name
Case "id"
Doc.ID = Text.ToString
End Select
End If
End Sub