Choosing the right IOS XML parser [closed]

Solution 1:

Best comparison I've seen on the subject:

http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project

The difference between the slowest and fastest parsers in his case was a factor of 2. Depending on your feature requirements, there are definitely parsers that can cut your parsing time in half.

Solution 2:

Check out RaptureXML. It's not official XPath behavior, but it's pretty close. Your query would be:

[rxml iterate:@"comments.comment" with: ^(RXMLElement *e) {
    if ([[e child:@"author"].text isEqualToString:@"foo1"]) {
        NSLog(@"Blog Text is %@.", e.text);
    } else {
        NSLog(@"Comment Text is %@.", e.text);
    }
}];

UPDATE: RaptureXML now supports XPath!

Solution 3:

You should look at these libraries, in order :)

  1. Ono, powered by libxml2
  2. XMLDictionary
  3. RaptureXML

Ono has the the cool AFOnoResponseSerializer which can be integrated with AFNetworking

Solution 4:

I made this new simple and lightweight XML parser for iOS in Swift - AEXML

You can use it to read XML data like this:

let someValue = xmlDocument["element"]["child"]["anotherChild"].value

or you can use it to build XML string like this:

let document = AEXMLDocument()
let element = document.addChild("element")
element.addChild("child")
document.xmlString // returns XML string of the entire document structure

I hope it will be useful for someone.