German HttpUtils2 and XMLSax

jeng

Member
Licensed User
Longtime User
Hallo,

Ich benötige ein bischen Hilfe hier mit.
Ich versuche diesen XML stream auszulesen.

Mit dieser XML-Datei sind anscheinend keine Style-Informationen verknüpft. Nachfolgend wird die Baum-Ansicht des Dokuments angezeigt.
<oscam version="1.20-unstable_svn build r8599" revision="8599" starttime="2013-04-05T08:46:08+0200" uptime="247" readonly="0">
<status>
<client type="s" name="root" desc="" protocol="server" protocolext="" au="0" thid="0x960a3f0">
<request caid="0000" srvid="0000" ecmtime="" ecmhistory="" answered=""/>
<times login="2013-04-05T08:46:08+0200" online="247" idle="1"/>
<connection ip="127.0.0.1" port="0">OK</connection>
</client>
<client type="r" name="imagin" desc="" protocol="mouse" protocolext="" au="-1" thid="0x9612e40">
<request caid="0000" srvid="0000" ecmtime="" ecmhistory="" answered=""/>
<times login="2013-04-05T08:46:08+0200" online="247" idle="247"/>
<connection ip="127.0.0.1" port="0">CARDOK</connection>
</client>
<client type="r" name="sat-hd+" desc="" protocol="mouse" protocolext="" au="-1" thid="0x9614a80">
<request caid="0000" srvid="0000" ecmtime="" ecmhistory="" answered=""/>
<times login="2013-04-05T08:46:08+0200" online="247" idle="247"/>
<connection ip="127.0.0.1" port="0">CARDOK</connection>
</client>
</status>

Ich habe den code von pixelpop aus dem englischen forum übernommen aber irgendwie klappt das nicht.
Ich bekomme einen access denied, trotz der definition von job1.Username and job1.Password.
Hier mein (pixelpop´s) code und log auszug.
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 headline, hl_short, hl_expanded, pubDate As String
    Dim ListView1 As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)

    Dim job1 As HttpJob
    job1.Initialize("Job1", Me)
    job1.Username = "test"
   job1.Password = "test"
    'Send a GET request
    job1.Initialize("Job1", Me)
    job1.DownLoad("http://192.168.178.220:8181/oscamapi.html?part=status")
    
End Sub
Sub JobDone (Job As HttpJob)

    Dim inputstr As InputStream
    
    If Job.Success = True Then
        inputstr = Job.GetInputStream
        parser.Parse(inputstr, "Parser")
    End If
    Job.Release
    
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
    If parser.Parents.IndexOf("headline") > -1 Then
        If Name = "times" Then
            pubDate = Text.ToString
        Else If Name = "connection" Then
            hl_short = Text.ToString
        Else If Name = "request" Then
            hl_expanded = Text.ToString
        End If
    End If
    If Name = "connection" Then
        ListView1.AddSingleLine2(hl_short, pubDate) 'add the title as the text and the link as the value
    End If
End Sub
Log File

** Activity (main) Resume **
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.example
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
startService: class b4a.example.httputils2service
** Service (httputils2service) Create **
** Service (httputils2service) Start **
Access denied.
** Service (httputils2service) Destroy **
** Activity (main) Resume **

Bin sehr Dankbar für jede Hilfe, und gedankenanstoss
 
Top