use GDataXML to parse xml in Xcode5

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”.

drag file to xcode project

drag file to xcode project

After this , we need to do some configuration in order to use this library.

  1. click the project name in the project navigator on the left hand side. this will open the editor interface in the middle main area.
  2. 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.
    click name in  target

    click name in target

    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.

    libxml2

    libxml2

    4. click the Build settings, search for “Header Search Path”, and double click it. select the + and add “usr/include/libxml2”.

    Header Search Path

    Header Search Path

    5. search for “other linker flags” and add “-lxml2” the same way as above.

    Other linker flags

    Other linker flags

     

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:

under 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.

 

Advertisements

4 comments

  1. SutoCom · October 22, 2013
  2. James Haule · January 31, 2014

    Very helpful , thank you

  3. OldEliDog · March 11, 2014

    Much better explanation than I’ve seen elsewhere. Thank you.

  4. Becky · July 15, 2014

    thank you!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s