I\'ve been wondering if there\'s a way to parse XML in Objective C as easily as parsing with SimpleXML in PHP.
The only existing methods I know are the following:
If you want to use libxml2
with an Objective-C front, take a look at this useful set of wrapper functions.
You issue an XPath query to your XML document object and get back Foundation class objects: NSArray
, NSString
, and NSDictionary
, e.g.:
NSArray *queriedBuckets = PerformXMLXPathQuery(responseData, @"//*[local-name()='Buckets']/*[local-name()='Bucket']");
These functions help unite the speed of libxml2
with the readability and usability of Objective-C code.