1

How do I parse OFX in iOS? OFX is formatted in SGML, and I can't find any good parsers to use in C or Objective-C on iOS.

2 Answers2

1

Try using libofx. It depends on OpenJADE for SGML but I've gotten them both to compile and work on iOS.

arolson101
  • 1,473
  • 15
  • 29
0

There are a few challenges here:

(1) OFX 1.x documents are SGML-based, while 2.x documents are XML-based, so if you know you will only deal with 2.x documents you could probably use an XML parser.

(2) If you do have to deal with 1.x documents, you'll have some code-lifting ahead of you. SGML in general and OFX 1.x in particular do not enforce close tags for simple types. That means you'll see things like:

<INVACCTFROM>
    <BROKERID>Fidelity Investments
    <ACCTID>FidRoth
</INVACCTFROM>

Parsing this kind of thing will be tricky unless you provide your own schema logic, or pre-process the data to a more "valid" format. An example of the latter, while not in C/Obj-C/C++, is given on Scott Hanselman's blog.

Good resources on OFX can be found here.

jstevenco
  • 2,913
  • 2
  • 25
  • 36
  • Yes I do need to deal with 1.x. Still looking for some C/Obj-C/C++ pre-processing, or libraries before I built it all myself. – user2175045 Mar 18 '13 at 01:54