Hello,
Let's consider the following simple xml file as xmlstring.
I'm using the following code to extract memories parameters in a list.
So I get in lstmems a list of maps with 2 maps.
Unfortunately sometimes can be a single memory definition in the xml file, so the returned value from Dim lstmems as List = mapdev.get("memory") is a map instead of a list.
There is a better way to deal with this than using Try .. Catch to capture the error and then to get a map instead of a list?
Thank you.
Let's consider the following simple xml file as xmlstring.
B4X:
<main>
<device>
<memory>
<param1>123456</param1>
<param2>654321</param2>
</memory>
<memory>
<param1>45678</param1>
<param2>87654</param2>
</memory>
</device>
</main>
I'm using the following code to extract memories parameters in a list.
B4X:
Dim xm as XML2MAP
xm.Initialize
Dim Parsed as Map = xm.Parse(xmlstring)
Dim mapdev as Map = Parsed.get("device")
Dim lstmems as List = mapdev.get("memory")
Unfortunately sometimes can be a single memory definition in the xml file, so the returned value from Dim lstmems as List = mapdev.get("memory") is a map instead of a list.
There is a better way to deal with this than using Try .. Catch to capture the error and then to get a map instead of a list?
Thank you.