如何在 iOS 上高效解析大型 xml 文件以将内容存储在 SQLite 中? [英] How to efficiently parsing large xml files on iOS in order to store the content in SQLite ?

查看:38
本文介绍了如何在 iOS 上高效解析大型 xml 文件以将内容存储在 SQLite 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 iPhone 应用程序中使用 libxml2 的 DOM 解析器来解析一个包含十万行的 XML 文件.

I'm using libxml2′s DOM parser in my iPhone app to parse a XML file with a hundred thousand lines.

我将检索到的内容存储到 SQLite 数据库中.但是,此过程需要几分钟才能完成,对用户友好.我的感觉是大部分时间都在将数据写入数据库时​​迷路了.

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.

推荐答案

尝试使用 Instruments 分析您的代码!检查您自己的代码中花费最多时间的部分!看看您是否可以采取不同的方法(或发布慢代码以获取建议)!如果可能,请使用 NSOperation/NSOperationQueue 向用户提供进度反馈!

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!

这篇关于如何在 iOS 上高效解析大型 xml 文件以将内容存储在 SQLite 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆