Sub XML_WriteXmlDataToMap(sXML As String, iDataMap As Map, PreEraseMap As Boolean)
'FUNCTION WHICH TAKES SIMPLE XML STRING
'AND WRITE IT TO MAP
'
'NOTE: AJDUSTED FOR MS ACCESS SCHEMA
Dim id1, id2 As Int 'data area start (id1) and end (id2) marked by "dataroot" tag
Dim it1, it2 As Int 'position of start tag
Dim it3, it4 As Int 'position of end tag
Dim i As Int 'cursor position
Dim sKey, sValue As String
'CLEAR MAP IF REQUESTED
If PreEraseMap Then iDataMap.Clear
'LOCATE START (id1) AND END (id2) OF DATA .. marked with "dataroot" for MS Access schema
id1 = sXML.IndexOf("<dataroot")
id1 = sXML.IndexOf2(">", id1) + 1
id2 = sXML.IndexOf("</dataroot>") - 1
'LOOP FROM id1 TO id2
i = id1
Do While i < id2
it1 = sXML.IndexOf2("<", i) 'find start pos of start tag
it2 = sXML.IndexOf2(">", it1) 'find end pos of start tag
sKey = sXML.SubString2(it1+1, it2) 'take between them - key name
it3 = sXML.IndexOf2("</", it2) 'find start pos of end tag
it4 = sXML.IndexOf2(">", it3) 'find end pos of end tag
sValue = sXML.SubString2(it2+1, it3)
sValue = sValue.Replace("<","<").Replace(">",">")
iDataMap.Put(sKey, sValue)
i = it4+1 'move cursor to new pos
Loop
End Sub