I have this code to import a xml into database:
but I received the message:
"Same Map found twice in list. Each item in the list should include a different map object."
This message is in DBUtils and explains:
"Small check for a common error where the same map is used in a loop"
How can I fix this code?
Thanks in advance.
B4X:
Sub XOMBuilder1_BuildDone(XOMDocument1 As XOMDocument, Tag As Object)
XOMDocument1.IsInitialized
Dim RootElement As XOMElement
RootElement = XOMDocument1.RootElement
ItemsElements = RootElement.GetChildElementsByName("item")
Dim i, ElementsCount As Int
ElementsCount = ItemsElements.Size
For i = 0 To ElementsCount - 1
dbmap.Put("name", ItemsElements.GetElement(i).GetFirstChildElementByName("name").Value)
dbmap.Put("address", ItemsElements.GetElement(i).GetFirstChildElementByName("address").Value)
ListOfMaps.Add(dbmap)
Next
If ListOfMaps.Size > 0 Then
DBUtils.InsertMaps(SQL1, "mytable", ListOfMaps)
ListOfMaps.Clear
End If
End Sub
but I received the message:
"Same Map found twice in list. Each item in the list should include a different map object."
This message is in DBUtils and explains:
"Small check for a common error where the same map is used in a loop"
How can I fix this code?
Thanks in advance.