XmlSax number is 1 and 10

beowulf6

Member
Licensed User
Longtime User
Hello,

i am currently having a small problem with parsing an XML with XmlSax.

i have a list of categories in the xml and the additional entries that are related to there categories.

now i parse the categories id like that
B4X:
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
    If parser.Parents.IndexOf("kategorieliste-a") > -1 Then
         If Name = "id" Then
               katId = Text.ToString
           End If
         If katTitle <> "" AND katId <> "" Then
            ListViewCat1.AddSingleLine2(katTitle, katId) 'add the title as the text and the link as the value
         End If
    End If
End Sub

now i parse the items in another activity exactly like that with
B4X:
If parser.Parents.IndexOf("rezeptliste") > -1 Then
         If Name = "kat-a" Then
            rezCatA = Text.ToString
           End If
         If rezTitle <> "" AND rezDesc <> "" AND rezId <> "" AND ( rezCatA <> "" AND rezCatA = Main.activeCatAid ) Then
            ListViewRez.AddTwoLines2(rezTitle, rezDesc, rezId)
         End If
End If

it works really nice until i get to a category id with 10.
now items that should only visible in category 10 show up in category 1 too.

And debugging shows that the var rezCatA really shows the value 1.

but when i am opening category 10 it shows category 10.

am i doing something wrong here? or must be the error somewhere else?
I always think that
B4X:
rezCatA = Main.activeCatAid
should be
B4X:
rezCatA == Main.activeCatAid
but that does not work of course. ;)

Thanks for every hint.
 

beowulf6

Member
Licensed User
Longtime User
hi.

i think finally fixed it.

i removed the
B4X:
If rezTitle <> "" AND rezDesc <> "" AND rezId <> "" AND ( rezCatA <> "" AND rezCatA = Main.activeCatAid ) Then
part and added
B4X:
If Name = "rezept" Then
  If rezCatA = Main.activeCatAid Then
    ...
  end if
end if

so now it should read until the end of the "rezept" -tag with all the information inside it, which was not done before, even when i checked if all the needed information are set and cleared all vars after putting it into the listview.

now i have only one item that is not parsed correctly. but i think that is another topic.

this xml parsing is a bit hard in basic4android. :)

thanks anyway
 
Last edited:
Upvote 0
Top