There are many ways in iOS to parse xml including the one inside the SDK. However I am not a big fan of that. Most people still tends to use third party library to do this for convenience.
GDataXML is a library from google. which you can download from: http://code.google.com/p/gdata-objectivec-client/source/browse/trunk/Source/XMLSupport/
After you get these two files, just drag them into your project folder. A dialog will popup when you drag, remember to check the “Cop item into destination group’s folder”.
After this , we need to do some configuration in order to use this library.
- click the project name in the project navigator on the left hand side. this will open the editor interface in the middle main area.
- click the project name under “TARGETS” in the area that is just opened. remember to click the “All”, otherwise not all the option will show up.
3. click the build phase in the top, click the Link binary with libraries, click the “plus” and search for ‘libxml2’ , add it to the prject.
4. click the Build settings, search for “Header Search Path”, and double click it. select the + and add “usr/include/libxml2”.
5. search for “other linker flags” and add “-lxml2” the same way as above.
This should be the end of the configs. Now you can just “#import “GDataXMLNode.h” in the desired file and start using it.
One possible error is if you are using iOS 7 sdk which supports the ARC, you might encounter compiler problem since the GDataxml has not convert to ARC compatible.
You need to:
target -> Build Phases -> Compile Sources, double click on the file you want to disable the ARC feature and put
-fno-objc-arc the click on
Done. And it’s Done 😉
Please note, that if the file doesn’t exist on the list, you can just add it by clicking the + button and then perform the same work above.