开发者

XML parsers sometimes fail parsing large XML files on Android

I'm parsing large XML files (~1-2M) in my application. Occasionally parser fails when parsing some files.

Symptoms:

  1. Sometimes the same file is parsed successfully, sometimes - not.
  2. If parsing of a file fails it will take some time before the file can be parsed successfully again.
  3. I use 2 types of XML parsers: SAX (XMLReader) and Pull (XMLPullParser), both of them fail near the same place in the file.
  4. I use FileInputStream as the input source for parsers.
  5. The same file compressed via zip and then opened via ZipFile.getInpu开发者_开发知识库tStream (almost) always parsed successfully.
  6. I tryed to wrap FileInputStream with BufferedInputStream - nothing changed.
  7. If parsing fails the next attempts to parse the file fail in the same place in the file.

I believe there can be two causes:

  1. FileInputStream works incorrectly.
  2. XML parsers work incorrectly with FileInputStream's (I heard both parsers implemented on the same base in Android).

Please help to fix the problem or advise a workaround.

Thanks.


This is the case if you experience the problem only sometimes. If the problem occurs each time you run the application the problem could be with XML.

In my case I believe it is device (I have Samsung I5700) or sdcard issue, because none of my application's users report same problem.

I'm going to reformat sdcard with android or try/buy another one.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜