B4J Question Add a line in tableview from xml SaxParser

Timoune

Member
Hello,

I'm a new user of B4X and I'm working on my first apps with B4J.
When I'm trying to insert into a tableview the content of an xml file with the following code


B4X:
Sub Process_Globals
   Private fx As JFX
   Dim parser As SaxParser
   Private MainForm As Form
   Private TSearch As TextField
   Private TVALL As TableView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.SetFormStyle("UNIFIED")
   MainForm.RootPane.LoadLayout("Principal") 'Load the layout file.

   'parse the xml file
   parser.Initialize
   Dim in As InputStream
   in = File.OpenInput(File.DirAssets, "MIC.xml")
   parser.Parse(in, "Parser")
   in.Close
   MainForm.Show
End Sub
Sub TSearch_TextChanged (Old As String, New As String)

End Sub


Sub Parser_StartElement (Uri As String, Name As String, Attributes As Attributes)

End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
   Dim Row(5) As Object
  
   If parser.Parents.IndexOf("item") > -1 Then
     If Name = "CodeMIC" Then
       Row(0) = Text.ToString
     Else If Name = "MarketName" Then
       Row(1) = Text.ToString
     Else If Name = "Country" Then
       Row(2) = Text.ToString
     Else If Name = "RICCode" Then
       Row(3) = Text.ToString
     Else If Name = "BBGCode" Then
       Row(4) = Text.ToString
     End If
   End If
   If Name = "item" Then
     TVALL.Items.Add(Row)
   End If
End Sub

I have the message you can see in the attached screenshot in the table view.
I think, it's a reference problem but I don't find how to resolve it

Thanks
PS: I think i'm not in right thread, an administrator could move it in B4J thread ? ...
 

Attachments

  • Sans titre.png
    Sans titre.png
    9.6 KB · Views: 352
Last edited:
Top