I'm using libxml2′s DOM parser in my iPhone app to parse a XML file with a hundred thousand lines.
I store the content retrieved into a SQLite database. However, this process takes several minutes to complete, too much to be user friendly. My feeling is the biggest part of the time gets lost writing the data into the database.
I'm looking now for any hints on how to make this process more efficient.
Try profiling your code with Instruments! Check for the parts of your own code that are taking the most time! See if you can take a different approach (or post the slow code for suggestions)! If possible, use NSOperation / NSOperationQueue to provide progress feedback to the user!
!
Definitely agree with JNozzi. Profile your code first to see where the largest performance bottlenecks are. It's not clear whether it's the XML DOM tree parsing, the XML DOM tree traversal, or the SQLite insertions which are causing the biggest problem.
If DOM tree parsing (or even traversal) is the issue, you should seriously consider switching to one of libxml2's more efficient XML parsing tools: xmlTextReader (the XML pull api) or SAX (the XML push api). I recommend xmlTextReader:
http://xmlsoft.org/xmlreader.html
You might also have a look at this question: "How do I improve the performance of SQLite?"