0

parsing xml using C++ on iPhone

Posted by admin on Aug 23, 2009 in C++, iPhone

I am trying to import an X3d file into my iPhone application. I could use the NSXMLParser to do this, but I want to write as much of the application logic in C++ as possible. The reason I want to do this is that I would like to be able to port this application to a different platform in the future. NSXMLParser is only usable from Objective C. the iPhone has the libxml2 installed . This is an xml parsing library with a generous license (MIT).

In order to use it, you will need to add the library to your project.  I created a “libraries” folder and right clicked it.  Select “Add > Existing Frameworks”.  Navigate to /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib/libxml2.2.dylib.

You then need to add the following include directive in the file you want to use it:

#include <libxml/parser.h>

You need to add the library to your project search path.  Open project properties.  On the build tab, find “Search Paths” > “Header Search Paths”.  Add “/usr/include/libxml2″ to this path.  You should be able to compile and use libxml2 now.

Copyright © 2010 programming with passion All rights reserved. Theme by Laptop Geek.