simple xml parser for c++

david1969

Registered
Hi. Hope someone can help me. Is there an XML parser API supplied with OS X that can be used from a c++ project? I can only find reference to something that seems to require cocoa and objective c - CFXMLTree.

I'd ideally like to avoid xerces / xpat etc etc as all I want to do is very quickly read in an XML file and then create a bunch of objects with a 1-1 mapping to the elements in the xml doc. I.e. I don't really need an in-memory DOM as the XML is really just a structured file format for me.

Does anyone have any ideas?

thanks

David
 
TinyXML is a very small, fast, ISO C++ compliant compiler that will work on any platform with a ISO C++ compliant compiler. Very easy to use too.
 
SAX parsers are quite simple.. Apache Xerces conforms to SAX.. if you only use it as a sax-based parser, it would simplify things a lot.
 
But the problem with Xerces is that it's quite huge. If you don't use all that functionality, it still bloats up your app by quite a bit. That's been my experience anyway. I normally use TinyXML or expat for my XML processing needs, which admittedly aren't too taxing.
 
Thanks guys. Looks like TinyXML will do the trick. As an ex-microsoft developer I find it strange that Apple's XML API can only be accessed via only one of the main development languages on the platform - objective C. That certainly wasn't the case with MSXML. Is there really no way I can create a CFXMLTree object from a C++ project? Oh well. Thanks again for the info. cheers, David
 
Okay - I think I get it now. CFXML is an XML parser that is part of the (Carbon) Core Foundation (http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFXML/index.html) and can therefore be accessed via C++ (actually to access it from Cocoa/ObjectiveC you need to use the NSMXL wrapper API - I think).

However as it's just a parser and cannot create a DOM object, it's not so useful. Tinyxml seems to be working fine for the prototype I'm writing, especially as any code I write will be portable, the main drawback is that it doesn't provide validation. So when I add that in, I'll switch to either expat (sax-based) or xerces (dom-based). I think this is correct, but don't quote me on it - I'm new to mac.

Thanks all.
 
Back
Top