views:

1809

answers:

3

Hi,

I'm getting this XML response from TwitPic:

     <?xml version="1.0" encoding="UTF-8"?>
 <rsp stat="ok">
  <mediaid>abc123</mediaid>
  <mediaurl>http://twitpic.com/abc123&lt;/mediaurl&gt;
 </rsp>

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?

Thanks,

Jamie.

A: 

CoreFoundation has a library for parsing xml.

http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFXML/CFXML.html

if you are not developing for the apple platform, expat is a well known C XML parser :)

http://expat.sourceforge.net/

Nippysaurus
+2  A: 

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.

Nathan Kinsinger
+1  A: 

Did you ever, by chance, figure out how to do this? I'm losing hair trying to weed myself through SeismicXML example and others... for a three or four line response from twitpic, it's too much to handle for me right now. Anyone, just a simple snippet of code that isn't as complex as something like SeismicXML?