7 messages in com.googlegroups.android-developers[android-developers] Very slow XML pa...| From | Sent On | Attachments |
|---|---|---|
| David Given | 26 May 2008 09:22 | |
| Mark Murphy | 26 May 2008 10:01 | |
| David Given | 26 May 2008 12:12 | |
| Megha Joshi | 26 May 2008 13:53 | |
| David Given | 26 May 2008 14:45 | |
| Mark Murphy | 26 May 2008 15:30 | |
| David Given | 26 May 2008 16:38 |
| Subject: | [android-developers] Very slow XML parsing![]() |
|---|---|
| From: | David Given (dg...@cowlark.com) |
| Date: | 05/26/2008 09:22:17 AM |
| List: | com.googlegroups.android-developers |
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
I'm trying to write a library that interfaces to (a rather small) online database. As the database is largely static, I've persuaded the developers to give me an XML dump of the whole thing, which I'm replicating in an SQL database on the device.
This almost works well. The problem is, the Android XML parser in DocumentBuilder is horribly, horribly slow. I'm seeing XML parsing speeds of an utterly pathetic 5kB/second; this is on an emulator running on a 3.2GHz machine, *without* the debugger.
My download-and-parse code is as follows:
---snip--- HttpClient http = new HttpClient(); GetMethod method = new GetMethod(uri);
http.executeMethod(method); InputStream data = method.getResponseBodyAsStream();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setNamespaceAware(false);
Document document = dbf.newDocumentBuilder().parse(data); ---snip---
Am I doing anything wrong? Is there anything I can do to speed things up?
(Also, using DocumentBuilder.parse(uri) throws an exception complaining that I haven't provided an InputStream or a Reader. Is this normal?)
-- ┌─── dg@cowlark.com ───── http://www.cowlark.com ───── │ "I have always wished for my computer to be as easy to use as my │ telephone; my wish has come true because I can no longer figure out │ how to use my telephone." --- Bjarne Stroustrup




