iOS Question How to parse an xml stream returning from httpjob

davepamn

Active Member
Licensed User
Longtime User
B4X:
Private hd As HUD
Sub HandleList(Job As HttpJob)

    If Job.Success = False Then

        HD.ToastMessageShow("Error downloading list.", True)

        HD.ProgressDialogHide

        Return

    End If

    Dim Text As String
    Text = job.GetString

    Do While Text.IndexOf(">")>0

        Dim StartTag As Int

        Dim EndTag As Int

        StartTag=Text.IndexOf("<")

        EndTag=Text.IndexOf(">")+1

        Dim S As StringBuilder

        S.Initialize

        S.Append(Text)

        S=S.Remove(StartTag,EndTag)

        Text=S.ToString

    Loop

Dim p AsJSONParser
  p.Initialize(Text)

Dim oItems As List

    oItems =p.NextArray


    Dim sStatus As String
    Dim oRowMap As Map
    Dim sErrorMsg As String

    For i = 0 To oItems.Size - 1

        oRowMap=oItems.Get(i)

        sStatus=oRowMap.Get("sStatus")

        sErrorMsg=oRowMap.Get("sErrorMsg")

 
    Next

This my code work around

I need a xml parser
 
Last edited:

davepamn

Active Member
Licensed User
Longtime User
B4X:
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://www.xxx.com/">[{"sStatus":"Success","sErrorMsg":""}]</string>
 
Last edited:
Upvote 0

davepamn

Active Member
Licensed User
Longtime User
B4X:
Sub Parser_StartElement (Uri As String, Name As String, Attributes As Attributes)

I am getting an error that Attributes is "an unknown type". What library needs to be included to get around this error?
 
Upvote 0
Top