Android Question stop parsing xmlparser

Discussion in 'Android Questions' started by EddyW, Jul 8, 2015.

  1. EddyW

    EddyW Member Licensed User

    After receiving the xml (httputils2 + OkHttp lib), i parse the xml and it works fine.

    in the Parser_EndElement i check/read the <Code> and <Opmerking> tag and all other tags i dont need at this stage. How can i stop the parsing of the xml after i have the 2 tags i need?

    Below is a simple example of the xml i receive. The <Taken> hold normal much more data and takes a while to process each tag and

    -- XML Exampe ---
    <Opmerking>Mesage recieved corectly</Opmerking>
    -- XML Exampe ---

    Each XML i receive has a <Status> with CODE and Opmerking but below </Status> can be different.
    Code is use for parsing i tried return to stop parsing but that dont work.

    Public Sub GetStatus As Map
    Return mStatus
    End Sub

    Sub  Parser_StartElement (Uri As String, Name As StringAttributes As Attributes)
    If Name.ToUpperCase = "STATUS" Then
    If mStatus.IsInitialized = False Then
    End If
    End If
    End Sub

    Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
    Select Name.ToUpperCase
    Case "CODE"
    Case "OPMERKING"
    Case "STATUS"
    End Select
    End Sub
  2. Erel

    Erel Administrator Staff Member Licensed User

    Unless the xml is huge you can just ignore the events. Use a process global variable as a flag.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice