Yes I agree, it is a homework exercise to parse xml with NSXMLParser and update with DB.
Is there a opensource library available to export given table of sqlite db to an xml? where it can use field name as xml element/tag. I want to try some tested solution.
I'm developing a module where I'd to export tables to xml and import to db on demand.
I currently use https://github.com/skjolber/xswi to create the xml file. It is taking quite a long time and crash often (Could not allocate data buffer
) at the very end (after completig 90%), since the test data I've is around 100,000 records. I guess it is due to memory allocation, I do clear the NSDictionary used after each record and append to the file (not keeping everything memory).
Also the file generated is around 70-80 Mb where compressed version of file (.zip) is around 50k. Is it correct to create XML or CSV?
It would be开发者_JAVA技巧 really helpful if someone suggest a right method to proceed.
Usually xml only gets long and complicated when you utilise ALL the functionality, in the minimal case you should be able to create a simple xml file from a sqllite table just by writing out
<?xml version="1.0"?>
<tablename>
<row>
<columnname1>content</columnname1>
<columnname2>content</columnname2>
</row>
<row>
</row>
</tablename>
doing this in a loop in the iteration for each row should not need any memory allocations that would depend on the size of the table. You don't really need an external library to do that.
As for size, xml is not know for its terseness, but there is a lot of repetition so it would compress a lot.
NSXMLParser is an EventBase SAX-like parser, this means that it also should not have any problems with the size of the xml file. It should never build a representation of the whole xml file. I don't have any experience with xswi so I cannot speak for that.
As for the error message (you can find that in the source code of xswi), think about how objective-c handles memory and when autoreleased memory actually gets released. And then look at how you are using xswi
精彩评论