views:

98

answers:

3

I'm using libxml2′s DOM parser in my iPhone to parse a XML file with 100'000 lines and put the content into a db! This process takes several minutes to complete! Too much to be user friendly! Im looking now for any hints on how to make this process more efficient! I guess, that the biggest part of the time gets lost writing the data into the db!

Any hints are welcome! Maechi

+3  A: 

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!

!

Joshua Nozzi
+2  A: 

You might also have a look at this question: "How do I improve the performance of SQLite?"

nesium
+2  A: 

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

Todd Ditchendorf