How to solve the XML parsing performance issue on Android

后端 未结 8 1897
耶瑟儿~
耶瑟儿~ 2020-12-25 08:31

I have to read a XML file with about ~4000 lines on Android. First I tried the SimpleXML library because it\'s the easiest and it took about 2 minutes on my HTC Desire. So I

8条回答
  •  滥情空心
    2020-12-25 08:51

    If your parsing from a Socket its the I/O thats taking the time, not the parsing. Try consume the data first, then parse once loaded and measure the performance. If the file is too big then consider a BufferedInputStream with a very large buffer, this should improve performance for you.

    I very seriously doubt Simple XML is going to take 2 minutes to load 4000 lines, I realise a handset is going to be a lot slower than a workstation, however I can load 200,000 lines of XML in 600ms on my workstation.

提交回复
热议问题