Reputation: 11
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.
Upvotes: 1
Views: 770
Reputation: 1502
Try using libofx. It depends on OpenJADE for SGML but I've gotten them both to compile and work on iOS.
Upvotes: 1
Reputation: 2953
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.
Upvotes: 0