简体   繁体   English

如何将XML数据存储到sqlite数据库中

[英]How to store xml data into sqlite database

I have a xml format data which is came from server. 我有一个来自服务器的xml格式数据。 Now i want to store it into database and it should load on button click. 现在我想将其存储到数据库中,并应在单击按钮时加载。 How should i do this? 我应该怎么做?

enter code here

<qst_code>    7    </qst_code>
<qst_prg_code>    1     </qst_prg_code>
<qst_mod_code>    2   </qst_mod_code>







<qst_Question>What is not true about left dominant cardiology circulation?  </qst_Question>



<qst_opt1>It is seen in 20% of the population</qst_opt1>
<qst_opt2>Left circumflex artery supplies the Posterior descending artery</qst_opt2>
<qst_opt3>Left circumflex artery terminates as obtuse marginal branch</qst_opt3>
<qst_opt4>Left circumflex artery may originate from right coronary sinus</qst_opt4>
<qst_opt01>1</qst_opt01>
<qst_opt02>1</qst_opt02>
<qst_opt03>1</qst_opt03>



<qst_opt04>1</qst_opt04>
<qst_CorctOpt>1</qst_CorctOpt>
<qst_Marks>10</qst_Marks>
<qst_company_code>1</qst_company_code>
<user_code>1</user_code>

一种选择是,如果数据不是太大,则将其存储为字符串,否则将其分解为映射到sqlite的架构,并在加载时重新创建它。

If your XML data is large, I would rather change the data exchange type to json. 如果您的XML数据很大,我宁愿将数据交换类型更改为json。 XML parsing and then insert is a very expensive operation and is time-consuming. XML解析然后插入是非常昂贵的操作,并且很耗时。

Some issues which you will face with XML parsing and insert. XML解析和插入将面临一些问题。

a. 一种。 XML parsing is memory intensive and so you heap size will grow, you need to keep an eye on this as this might cause crash. XML解析占用大量内存,因此您的堆大小将会增加,因此需要注意这一点,因为这可能会导致崩溃。 b. b。 Inserts in SQLite DB will take around ~100ms per tuple (row), so you can calculate the time it will required to pump in thousands of rows of data. 每行(行)在SQLite DB中插入大约需要100毫秒,因此您可以计算抽入数千行数据所需的时间。

If you data is not too large don't bother about using SQLite. 如果您的数据不是太大,请不要担心使用SQLite。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将数据从XML文件存储到android中的SQLite数据库 - How to store data from XML file to SQLite database in android 如何将解析的xml文件存储到Android中的sqlite数据库? - how to store parsed xml file to a sqlite database in Android? 如何从中心数据库获取数据并存储在android sqlite数据库中? - How to fetch data from center database and store in android sqlite database? 如何从 SQLite 数据库中存储和获取大文本数据? - How to store and fetch large text data from SQLite database? 如何从mysql中获取数据并存储在android中的Sqlite数据库中 - How to fetch data from mysql and store in Sqlite database in android 如何将单行数据存储到android中的sqlite数据库的字符串数组中 - How to store a single row data into a string array of sqlite database in android 如何使用两个表在SQLite数据库中存储多个数据? - How to store multiple data in SQLite Database using two tables? 如何从意图中获取数据并存储在 sqlite 数据库中? - How to get data from intent and store in the sqlite database? 如何在SQLite数据库中存储和检索字节数组(图像数据)? - How to store and retrieve a byte array (image data) to and from a SQLite database? 如何将数据存储到外部sqlite数据库并在RecyclerView中显示 - How to store data to external sqlite database and display in RecyclerView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM