This is just a simplified example to explain the issue I have.
I'm using XML2MAP to covert a simple xml file:
And the following code:
And the routine GetElements
The problem is that if I save the map and theN I read it from the file, GetElements(mp,"config") does no more return a list, but a single element as a string.
Logging the two 'value' objects, looks absolutely the same.
I am doing something wrong?
Thank you
I'm using XML2MAP to covert a simple xml file:
B4X:
<root>
<config>
<param1>val11</param1>
<param2>val12</param2>
<param3>val13</param3>
</config>
<config>
<param1>val21</param1>
<param2>val22</param2>
<param3>val23</param3>
</config>
</root>
And the following code:
B4X:
Dim Parsed As Map = xm.Parse(xmlfile)
Dim mp as Map = Parsed.Get("list")
Dim lst As List
lst = GetElements(mp,"config")
Log("lst size = " & lst.Size)
File.WriteMap(File.DirInternal,"example.map",mp)
mp = File.ReadMap(sLocalRepository,"example.map")
lst = GetElements(mp,"config")
Log("lst size = " & lst.Size)
And the routine GetElements
B4X:
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
value = m.Get(key)
Log(key & ": " & value)
If value Is List Then Return value
res.Initialize
res.Add(value)
Return res
End If
End Sub
The problem is that if I save the map and theN I read it from the file, GetElements(mp,"config") does no more return a list, but a single element as a string.
Logging the two 'value' objects, looks absolutely the same.
I am doing something wrong?
Thank you
Last edited: