Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

XLM import into access not working

Posted on 2013-11-12
4
Medium Priority
?
708 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

886 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