SimpleXML way of parsing in Objective C for iPhone App

前端 未结 1 1705
名媛妹妹
名媛妹妹 2021-01-07 13:14

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:

相关标签:
1条回答
  • 2021-01-07 14:07

    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.

    0 讨论(0)
提交回复
热议问题