Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C DOM XML parser for iPhone

Hello guys I'm looking for a way on the iPhone to parse an XML document using DOM. I have been using SAX with NSXMLParser but now I really want a DOM tree (or anything that can quickly translate the XML document into an NSDictionary)
Thanks for any help

like image 745
phunehehe Avatar asked Sep 30 '09 04:09

phunehehe


1 Answers

If you want to use libxml2 with an Objective-C front without SAX events, 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 merge the speed of libxml2 with the readability and usability of Objective-C code.

like image 176
Alex Reynolds Avatar answered Oct 13 '22 16:10

Alex Reynolds