Hello guys
I am trying to make a feed reader based on the XmlSax library and sample but I am having problems with parse...
In this case I need download and save the page with xml.
There is an error in parse and I couldn't solve it....
Can anyone give a help?
follow my code:
I am trying to make a feed reader based on the XmlSax library and sample but I am having problems with parse...
In this case I need download and save the page with xml.
There is an error in parse and I couldn't solve it....
Can anyone give a help?
follow my code:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim parser As SaxParser
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 Listview1 As ListView
'
Dim Title, Link As String
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("webview")
If FirstTime Then
parser.Initialize
End If
Listview1.Initialize("ListView1")
Activity.AddView(Listview1, 0, 0, 100%x, 100%y)
Listview1.SingleLineLayout.ItemHeight = 60dip
download_page
'parse the xml file
Dim in As InputStream
in = File.OpenInput(File.DirInternal,"stj.xml")
parser.Parse(in,"Parse")
in.Close
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub download_page
Link="https://res.stj.jus.br/hrestp-c-portalp/RSS.xml"
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Link)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim out As OutputStream=File.OpenOutput(File.DirInternal,"stj.xml",False)
File.Copy2(j.GetInputStream,out)
out.Close
End If
j.Release
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)
If parser.Parents.IndexOf("item") > -1 Then
If Name = "title" Then
Title = Text.ToString
Else If Name = "link" Then
Link = Text.ToString
End If
End If
If Name = "item" Then
Listview1.AddSingleLine2(Title, Link) 'add the title as the text and the link as the value
End If
End Sub
Last edited: