Sub Process_Globals
Dim parser As SaxParser
Type Item (Title As String, Link As String)
Dim Items As List
Dim key As String
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
parser.Initialize
Items.Initialize
Dim in As InputStream
in = File.OpenInput(File.DirAssets, "list.xml")
parser.Parse(in, "parser")
in.Close
End If
End Sub
Sub Parser_StartElement (Uri As String, Name As String, Attributes As Attributes)
If Name = "dict" Then
Dim i As Item
i.Initialize
Items.Add(i)
End If
End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
If Name = "key" Then
key = Text.ToString
Else If Name = "string" Then
Dim i As Item
i = Items.Get(Items.Size - 1) 'get the last added item
Select key
Case "title"
i.Title = Text.ToString
Case "link"
i.Link = Text.ToString
End Select
End If
End Sub