Hi All,
I have a huge xml. In it there is a node: <INDIVIDUAL_PLACE_OF_BIRTH/>. This is a normal empty node.
I read the xml with xml2map like below and I get an exception - only if I in release mode!:
(ClassCastException) java.lang.ClassCastException: java.lang.String cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap'
I can understand, this isn't a map, this is an empty node. But how can I check it?
I tried with: if lm is Map then ... end if. It works in debug mode, but not in release mode.
I tried try / catch / end try, It works in debug mode, but not in release mode.
I tried For Each lm As object In Codebase.GetElements(m, kk(0)) / if lm is map then ... It works in debug mode, but not in release mode.
I tried other ways also, but no success.
How can I find out, that it is an empty node?
thanks
Steven
I have a huge xml. In it there is a node: <INDIVIDUAL_PLACE_OF_BIRTH/>. This is a normal empty node.
I read the xml with xml2map like below and I get an exception - only if I in release mode!:
(ClassCastException) java.lang.ClassCastException: java.lang.String cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap'
I can understand, this isn't a map, this is an empty node. But how can I check it?
I tried with: if lm is Map then ... end if. It works in debug mode, but not in release mode.
I tried try / catch / end try, It works in debug mode, but not in release mode.
I tried For Each lm As object In Codebase.GetElements(m, kk(0)) / if lm is map then ... It works in debug mode, but not in release mode.
I tried other ways also, but no success.
How can I find out, that it is an empty node?
thanks
Steven
B4X:
'kk(0) = "INDIVIDUAL_PLACE_OF_BIRTH"
For Each lm As Map In Codebase.GetElements(m, kk(0))
If lm.ContainsKey(kk(1)) Then 'here is an exception:
If attribute.Length > 0 Then
Dim mm As Map = lm.Get(kk(1))
Dim amapl As Map = mm.Get("Attributes")
If amapl.ContainsKey(attribute) Then
Return amapl.Get(attribute)
Else
Return Null
End If
Else
Return lm.Get(kk(1))
End If
End If
Next
...
Sub GetElements (m As Map, key As String) As List
Dim res As List
If m.ContainsKey(key) = False Then
res.Initialize
Return res
Else
Dim value As Object = m.Get(key)
If value Is List Then Return value
res.Initialize
res.Add(value)
Return res
End If
End [ATTACH type="full"]117724[/ATTACH]Sub
Attachments
Last edited: