Bikal Lem
Bikal Lem

Reputation: 2423

OFX File parser in C#

I am looking for an OFX file parser library in C#. I have search the web but there seems to be none. Does anyone know of any good quality C# OFX file parser. I need to process some bank statements files which are in OFX format.

Update I have managed to find a C# library for parsing OFX parser.

Here is the link ofx sharp. This codebase seems to be the best case to startup my solution.

Upvotes: 4

Views: 9271

Answers (2)

Jo-Pierre
Jo-Pierre

Reputation: 145

I tried to use the ofx sharp library, but realised it doesn't work is the file is not valid XML ... it seems to parse but has empty values ...

I made a change in the OFXDocumentParser.cs where I first fix the file to become valid XML and then let the parser continue. Not sure if you experienced the same issue?

Inside of the method:

private string SGMLToXML(string file)

I added a few lines first to take file to newfile and then let the SqmlReader process that after the following code:

string newfile = ParseHeader(file);

newfile = SGMLToXMLFixer.Fix_SONRS(newfile);
newfile = SGMLToXMLFixer.Fix_STMTTRNRS(newfile);
newfile = SGMLToXMLFixer.Fix_CCSTMTTRNRS(newfile);


//reader.InputStream = new StringReader(ParseHeader(file));
reader.InputStream = new StringReader(newfile);

SGMLToXMLFixer is new class I added into the OFXSharp library. It basically scans all the tags that open and verifies it has a closing tag too.

namespace OFXSharp
{
    public static class SGMLToXMLFixer
    {
        public static string Fix_SONRS(string original) 
        { .... }

        public static string Fix_STMTTRNRS(string original) 
        { .... }

        public static string Fix_CCSTMTTRNRS(string original) 
        { .... }

        private static string Fix_Transactions(string file, string transactionTag, int lastIdx, out int lastIdx_new) 
        { .... }

        private static string Fix_Transactions_Recursive(string file_modified, int lastIdx, out int lastIdx_new) 
        { .... }

    }
}

Upvotes: 1

John Warlow
John Warlow

Reputation: 2992

Try http://www.codeproject.com/KB/aspnet/Ofx_to_DataSet.aspx. The code uses Framework 3.5 and transforms an ofx into a dataset, this may help with what you're trying to do.

Upvotes: 0

Related Questions