views:

39

answers:

1

I have an iPhone App that reads in an XML file, then pulls out the necessary data by looping through an NSScanner. The XML is not particularly long.

I am wondering if it would be worth the work to implement NSXMLParser in place of using NSScanner, if I will see any real improvement in speed?

A: 

There's a nice comparison article for different XML parsers:

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

The guy uses 900kb (!!!) XML file as a test sample, and the results are quite interesting: NSXMLParser is by far the slowest. That said, I think NSXMLParser on it's own uses NSScanner (or similar) + extra processing for bells and whistles related to XML.

If your solution works fine and is easy to maintain, I would not switch to any specialized parser. However if you are planning to extend your XML usage, it's probably a good idea to start using one.

Nick