开发者

What are the various options to parse a XML in android mobile device?

I have a huge set of xmls(2000 files each having 500 lines) to be parsed in Android for fetching the information f开发者_如何学编程rom it. All the files will be present in the device. I had this to be done in iPhone and i accomplished it by converting all the XMLs to PLIST files. The PLIST processing in a iOS was faster than parsing a XML in iphone. Similarly for android is there any options available? or What are the best way to parse those XMLs in android as i feel the same problem we had in iphone(performance incurred in parsing) will be here also?


I don't know which parsing mechanism you've used on iOS and how they behave there. All I can tell you that you should consider using the SAX parser over all other available parsing mechanisms.

The SAX parser produces a relatively small memory footprint compared to the DOM parser as it doesn't load the whole document into memory first. It reads the document line by line and informing you of events like starting tag, content, ending tag and the like as they appear.

Here is the reference page on one of the SAX implementations shipped with Android. There is an Android SAX implementation too you have to find out yourself which one works best for you.

Good luck.


I'd use XML pull parsing. Here's the class for it. Some info about xml processing performance

Afaik, in the new Android version (2.2) they implemented a better json parser. I think you should try converting your xmls to json format, and try both out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜