[dba-Tech] XML to access?

MartyConnelly martyconnelly at shaw.ca
Sun Sep 4 14:03:21 CDT 2005


I have some basic error handler code for SAX parsing both with and 
without an xsd file
Avoids a lot of head scratching.
I didn't think of building fields in the table this way, I was going to 
do it from an xsd file.

'To invoke error handling

  Set m_oIError = New IErrorHandler
 with Reader
  Set .errorHandler = m_oIError
        .putFeature "schema-validation", True
        .putFeature "exhaustive-errors", True
        .putFeature "use-schema-location", False 'not using xsd file
and
'----------------------------------------------------
'Class IErrorHandler.cls
'----------------------------------------------------


Implements IVBSAXErrorHandler

Private Sub IVBSAXErrorHandler_error(ByVal oLocator As 
MSXML2.IVBSAXLocator, strErrorMessage As String, ByVal nErrorCode As Long)
    MsgBox "Error " & strErrorMessage & " - line " & oLocator.lineNumber 
& " ,column " & oLocator.columnNumber & _
     " - " & oLocator.publicId
    Debug.Print strErrorMessage & " - line " & oLocator.lineNumber & " 
,column " & oLocator.columnNumber & _
      " - " & oLocator.publicId
End Sub

Private Sub IVBSAXErrorHandler_fatalError(ByVal oLocator As 
MSXML2.IVBSAXLocator, strErrorMessage As String, ByVal nErrorCode As Long)
    MsgBox "Fatal " & strErrorMessage & " - line " & oLocator.lineNumber 
& " ,column " & oLocator.columnNumber
    Debug.Print strErrorMessage & " - line " & oLocator.lineNumber & " 
,column " & oLocator.columnNumber
   
End Sub

Private Sub IVBSAXErrorHandler_ignorableWarning(ByVal oLocator As 
MSXML2.IVBSAXLocator, strErrorMessage As String, ByVal nErrorCode As Long)
    MsgBox "Warning " & strErrorMessage & " - line " & 
oLocator.lineNumber & " ,column " & oLocator.columnNumber
    Debug.Print strErrorMessage & " - line " & oLocator.lineNumber & " 
,column " & oLocator.columnNumber
End Sub

'----------------------------------------------------

Shamil Salakhetdinov wrote:

>Jon,
>
>I did publish here http://smsconsulting.spb.ru/vdv/?postid=24 several
>relatively simple methods to code XML import in VBA.
>
>HTH,
>Shamil
>
>P.S. What is your XML file structure?
>
>----- Original Message ----- 
>From: "Jon Tydda" <Jon.Tydda at alcontrol.co.uk>
>To: "Dba-Tech (E-mail)" <dba-tech at databaseadvisors.com>
>Sent: Thursday, September 01, 2005 7:38 PM
>Subject: [dba-Tech] XML to access?
>
>
>  
>
>>Hi all
>>
>>I've not used access much, but as the IT guy here, I've been asked to try
>>and find a way to import data into an access db from an xml sheet, which
>>    
>>
>is
>  
>
>>seemingly the only way we can oupput from the software we have.
>>
>>So in view of it being the blind leading the blind, as such, is there a
>>SIMPLE way to do it?
>>
>>
>>Jon
>>
>>
>>    
>>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the dba-Tech mailing list