Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

XLM import into access not working

Posted on 2013-11-12
4
Medium Priority
?
718 Views
Last Modified: 2013-12-03
I have an existing import routine that import xml.  It is importing payroll data.   The xml document looks like this:

<?xml version="1.0" ?>
<?pcxml version="2.0" ?>
<PCXML>

<Company>
<ID>55-5555555</ID>
<BusinessName>My Company, Inc.</BusinessName>
</Company>
<AccountAddRq>
<AccountAdd>
<Name>1-4000</Name>
<AccountType>OtherCurrentAsset</AccountType>
<Desc>Asset Account - Employee Deductions</Desc>
</AccountAdd>
</AccountAddRq>
<AccountAddRq>
<AccountAdd>
<Name>7-2250</Name>
<AccountType>Expense</AccountType>
<Desc>Tax Account - 7-2250</Desc>
</AccountAdd>
</AccountAddRq>
<AccountAddRq>
<AccountAdd>
<Name>7-2280</Name>
<AccountType>Expense</AccountType>
<Desc>Tax Account - 7-2280</Desc>
</AccountAdd>
</AccountAddRq>
<AccountAddRq>
<AccountAdd>

Open in new window


It has the <?xml version="1.0" ?>
<?pcxml version="2.0" ?>
<PCXML> tags in it, and also no unclosed tags.

The import that does not work is a quicken qfx file.  It has many header items and unclosed tags.  THis file starts like this.

OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE

<OFX>
<SIGNONMSGSRSV1>
<SONRS>
<STATUS>
<CODE>0
<SEVERITY>INFO
<MESSAGE>Success
</STATUS>
<DTSERVER>20131101123601.000
<LANGUAGE>ENG
<FI>
<ORG>CITIGROUP
<FID>999999
</FI>
<INTU.BID>999999<INTU.USERID>9999999999
</SONRS>
</SIGNONMSGSRSV1>
<CREDITCARDMSGSRSV1>
<CCSTMTTRNRS>
<TRNUID>0
<STATUS>
<CODE>0
<SEVERITY>INFO
<MESSAGE>Success
</STATUS>
<CCSTMTRS>
<CURDEF>USD
<CCACCTFROM>
<ACCTID>XXXXXXXXXXXX9999
</CCACCTFROM>
<BANKTRANLIST>
<DTSTART>20131003180000.000
<DTEND>20131030180000.000
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20131003180000.000
<TRNAMT>-3.02
<FITID>0483132760001
<SIC>8699
<NAME>WWW.LINKEDIN.COM       MOUNTAIN
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20131003180000.000
<TRNAMT>-14.24
<FITID>99999999999992
<SIC>7399

Open in new window


So, the question is how to make access parse this file??

My module looks like this:

Function fImportCITI(strXML As String)
' to import citibank credit card statments from stmt.qfx file (quicken format)
    On Error GoTo PROC_ERR
    Dim xmlDOM As DOMDocument
    Dim xmlNodeList As IXMLDOMNodeList
    Dim xmlNodeItem As IXMLDOMNode
    Dim xmlNodeField As IXMLDOMNode
    Dim xmlNodeSubItem As IXMLDOMNode
        
    Dim cnn As New ADODB.Connection
    Dim rstTmpCC As New ADODB.Recordset
    'Dim rstTmpCCItems As New ADODB.Recordset
    Dim sql As String
    'Dim sqlCCItems As String
    Dim PayableID As Long
    Dim netCheck As Currency

    Set cnn = CurrentProject.Connection
    sql = "Select * from tmpCCImportsStagingData"
    'sqlPL = "Select * from [tmpCCImportsStagingDataBU]"
   
    Debug.Print Dir(strXML)
   
    Set xmlDOM = New DOMDocument
    
    
    
    If xmlDOM.Load(strXML) Then
    Debug.Print "doc loaded"
    Else
    Debug.Print "nope"
    End If
   
      
      ' Set xmlNodeItem = xmlDOM.documentElement.childNodes.Item(0)
             
         '   Debug.Print "xmlNodeItem.childNodes.length-" & xmlNodeItem.childNodes.Length
         '   Debug.Print "xmlNodeItem.childNodes(0).Text-" & xmlNodeItem.childNodes(0).Text
         '   Debug.Print "xmlNodeItem.childNodes(1).Text-" & xmlNodeItem.childNodes(1).Text
   
     If Err.Number = 91 Then
        Debug.Print "error 91"
    Else
        Debug.Print "no error 91"
        
    End If
      Set xmlNodeList = xmlDOM.getElementsByTagName("STMTTRN")
      
Debug.Print "Setup check recordset"

Open in new window



Many Thanks, Press
0
Comment
Question by:pressMac
  • 2
4 Comments
 
LVL 25

Expert Comment

by:chaau
ID: 39643408
Can you have Quicken to generate a different file format, i.e. CSV?
0
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 1500 total points
ID: 39643704
I assume you are downloading this from a financial institution that does not have a csv (excel) export format.

I looked into reading the OFX and QFX formats in the past. It is my understanding that the OFX and QFX formats are in SGML not standard XML.  Because it is SGML it makes hte OFX/QFX a VERY complex spec. Since my financial institutions offer csv as an export format I decided to skip trying to read OFX/QFX.

ALERT: Developing an SGML parser is an extremely difficult task

At one time I looked into using these to convert SGML to XML for importing into Access:

1)  SGMLReader at https://github.com/mindtouch/sgmlreader
Converts the given OFX file to XML using the SGML DTD "ofx160.dtd" specified in the test.ofx file.

sgmlreader -dtd ofx160.dtd test.ofx ofx.xml


2)  n2x: An environment for translating SGML to XML  found here: http://www.cranesoftwrights.com/resources/n2x/index.htm
This Python program works with the output from James Clark's NSGMLS tool (found in the same SP package referenced above) to create XML syntax from the parsed content of an SGML document.

If you have a lot of time to work on this and will be repeating it a lot then it may be worth writing this.

Otherwise you might want to consider ProperSoft's products:

 1) Bank2CSV at  http://download.cnet.com/Bank2CSV/3000-10743_4-75219741.html


CNET Download.com
ProperSoft's Bank2CSV is a utility that converts your electronic bank and credit card statements from the OFX, QFX, QIF, QBO, and OFC formats used by programs such as QuickBooks, Quicken, and Microsoft Money into spreadsheet-compatible Comma Separated Value (CSV) files.

2) QFX2CSV at http://www.propersoft.net/qfx2csv/ 
Convert Quicken Web Connect (QFX) bank, credit card, or investment activity file to CSV (Excel) format
0
 

Author Closing Comment

by:pressMac
ID: 39693596
Not really the solution i hoped for.  But i wont spend more time trying to read file natively.  So it is a solution of sorts.

Press
0
 
LVL 21
ID: 39693634
Press,

I am coding a solution for importing OFX and QFX files this into Access. I will let you know when I get it done.
0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Implementing simple internal controls in the Microsoft Access application.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question