Objective-c – Navigating XML from Objective-C


I'm getting this XML response from TwitPic:

     <?xml version="1.0" encoding="UTF-8"?>
    <rsp stat="ok">

I want to access the value within the 'mediaurl' tags.

So I tried:

NSString *twitpicURL = [[request responseHeaders] objectForKey:@"mediaurl"];

But that doesn't seem to work.

Can someone point me in the right direction with this please?



Best Solution

Apple has NSXMLDocument (available on Mac OS X only) and NSXMLParser (available on Mac OS X and iPhone) both are based on the open source C library Libxml2 (available on Mac OS X and iPhone).

If you decide to use NSXMLDocument I would suggest using XPath as a quick/simple way to get the data.