Mojo
2011-03-24 19:52:48 UTC
Hi All
I've created 2 apps in VB6 that store and use data within their own Access
2000 DBs.
Now data needs to pass between these 2 apps quite regularly so I decided to
go with what seems to be the standard convention of an XML export file.
This seemed to work fine until the amount of data going into the XML file
increased. Now an import run contains about 12-15 xml files, with each xml
file ranging from around 700KB to 3MB in size, but these surely aren't
massive files by any means.
In my import sequence I use the following code:
' == gather files list for xml
dirImports.Path = strChosenImportFolderPath
dirImports.Pattern = "*.xml"
dirImports.Refresh
lsvImports.ListItems.Clear
If dirImports.ListCount > 0 Then
For x = 0 To dirImports.ListCount - 1
If oXML.Load(strChosenImportFolderPath & "/" & dirImports.List(x)) Then
bolFileCheck = False
If oXML.documentElement.baseName = "ManagerImport" Then
Set oDateCreated = oXML.getElementsByTagName("DateCreated")
If oDateCreated.length > 0 Then
strRawImportDate = oDateCreated.Item(0).Text
bolFileCheck = True ' valid file exists
End If
Else
strRawImportDate = "000000000000"
End If
If bolFileCheck = True Then
strRawImportClass = dirImports.List(x)
If InStr(1, strRawImportClass, "_M-export") > 0 Then ' format class name
intStartPos = InStr(1, strRawImportClass, "_") + 1
intEndPos = InStr(1, strRawImportClass, "_M-export")
If intEndPos > intStartPos Then
strFormatedImportClass = Mid(strRawImportClass, intStartPos,
intEndPos - intStartPos)
Else
strFormatedImportClass = ""
End If
End If
strFormatedImportClass = Replace(strFormatedImportClass, "_", " ")
strFormatedImportDate = ReFormatExportDate(strRawImportDate)
Else
strFormatedImportClass = ""
strFormatedImportDate = ""
End If
Set oListItem = lsvImports.ListItems.Add(, , dirImports.List(x))
oListItem.SubItems(1) = strFormatedImportClass
oListItem.SubItems(2) = strFormatedImportDate
oListItem.SubItems(3) = strRawImportDate
If Len(oListItem.SubItems(2)) > 0 And oListItem.SubItems(2) <> "Not
Applicable" Then oListItem.Checked = True
Next
End If
I know there is a lot there, but I just wanted to give you the full IF...
END IF sequence. The problem I have is that the listview is in humngo
pregnant pause mode as it tries to do the above. Users thought the app had
locked up because it takes ages to bring up the list of 12-15 files in the
listview. The big thing is that none of the above creates this problem
apart from the below:
Set oDateCreated = oXML.getElementsByTagName("DateCreated")
If oDateCreated.length > 0 Then
strRawImportDate = oDateCreated.Item(0).Text
.... ......
The XML Load and read seems to completely freeze the process. Don't get me
wrong it will complete, but it seems to take forever on what seems like a
trivial bit of data.
Am I expecting too much from XML or am I coding the wrong way for this bit
of data?
Any advice you can give would be very much appreciated.
I've created 2 apps in VB6 that store and use data within their own Access
2000 DBs.
Now data needs to pass between these 2 apps quite regularly so I decided to
go with what seems to be the standard convention of an XML export file.
This seemed to work fine until the amount of data going into the XML file
increased. Now an import run contains about 12-15 xml files, with each xml
file ranging from around 700KB to 3MB in size, but these surely aren't
massive files by any means.
In my import sequence I use the following code:
' == gather files list for xml
dirImports.Path = strChosenImportFolderPath
dirImports.Pattern = "*.xml"
dirImports.Refresh
lsvImports.ListItems.Clear
If dirImports.ListCount > 0 Then
For x = 0 To dirImports.ListCount - 1
If oXML.Load(strChosenImportFolderPath & "/" & dirImports.List(x)) Then
bolFileCheck = False
If oXML.documentElement.baseName = "ManagerImport" Then
Set oDateCreated = oXML.getElementsByTagName("DateCreated")
If oDateCreated.length > 0 Then
strRawImportDate = oDateCreated.Item(0).Text
bolFileCheck = True ' valid file exists
End If
Else
strRawImportDate = "000000000000"
End If
If bolFileCheck = True Then
strRawImportClass = dirImports.List(x)
If InStr(1, strRawImportClass, "_M-export") > 0 Then ' format class name
intStartPos = InStr(1, strRawImportClass, "_") + 1
intEndPos = InStr(1, strRawImportClass, "_M-export")
If intEndPos > intStartPos Then
strFormatedImportClass = Mid(strRawImportClass, intStartPos,
intEndPos - intStartPos)
Else
strFormatedImportClass = ""
End If
End If
strFormatedImportClass = Replace(strFormatedImportClass, "_", " ")
strFormatedImportDate = ReFormatExportDate(strRawImportDate)
Else
strFormatedImportClass = ""
strFormatedImportDate = ""
End If
Set oListItem = lsvImports.ListItems.Add(, , dirImports.List(x))
oListItem.SubItems(1) = strFormatedImportClass
oListItem.SubItems(2) = strFormatedImportDate
oListItem.SubItems(3) = strRawImportDate
If Len(oListItem.SubItems(2)) > 0 And oListItem.SubItems(2) <> "Not
Applicable" Then oListItem.Checked = True
Next
End If
I know there is a lot there, but I just wanted to give you the full IF...
END IF sequence. The problem I have is that the listview is in humngo
pregnant pause mode as it tries to do the above. Users thought the app had
locked up because it takes ages to bring up the list of 12-15 files in the
listview. The big thing is that none of the above creates this problem
apart from the below:
Set oDateCreated = oXML.getElementsByTagName("DateCreated")
If oDateCreated.length > 0 Then
strRawImportDate = oDateCreated.Item(0).Text
.... ......
The XML Load and read seems to completely freeze the process. Don't get me
wrong it will complete, but it seems to take forever on what seems like a
trivial bit of data.
Am I expecting too much from XML or am I coding the wrong way for this bit
of data?
Any advice you can give would be very much appreciated.