Solved

XLM import into access not working

Posted on 2013-11-12
4
658 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

710 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