Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7780945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:04:05+00:00 2026-06-01T19:04:05+00:00

I have to read a XML file with about ~4000 lines on Android. First

  • 0

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 thought maybe SimpleXML is so slow because of reflection and all the other magic that this library uses. I rewrote my parser and used the built-in DOM parsing method with some special attention for performance. That helped a bit but it still took about 60 seconds which is still totally unacceptable. After a bit of research I found this article on developer.com. There are some graphs that show that the other two available methods – the SAX parser and Android’s XML Pull-Parser – are equally slow. And at the end of the article you’ll find the following statement:

The first surprise I had was at how slow all three methods were. Users
don’t want to wait long for results on mobile phones, so parsing
anything more than a few dozen records may mandate a different method.

What might be a “different method”? What to do if you have more than “a few dozen records”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:04:06+00:00Added an answer on June 1, 2026 at 7:04 pm

    Original answer, in 2012

    (note: make sure you read the 2016 update below!)

    I just did some perf testing comparing parsers on Android (and other platforms). The XML file being parsed is only 500 lines or so (its a Twitter search Atom feed), but Pull and DOM parsing can churn through about 5 such documents a second on a Samsung Galaxy S2 or Motorola Xoom2. SimpleXML (pink in the chart) as used by the OP ties for slowest with DOM parsing.

    SAX Parsing is an order of magnitude faster on both of my Android devices, managing 40 docs/sec single-threaded, and 65+/sec multi-threaded.

    Android 2.3.4:

    performance comparison of xml parsing methods on Android

    The code is available in github, and a discussion here.

    Update 18th March 2016

    OK, so its been almost 4 years and the world has moved on. I finally got around to re-running the tests on:

    1. A Samsung Galaxy S3 running Android 4.1.2
    2. A Nexus7 (2012) running Android 4.4.4
    3. A Nexus5 running Android 6.0.1

    Somewhere between Android 4.4.4 and Android 6.0.1 the situation changed drastically and we have a new winner: Pull Parsing FTW at more than twice the throughput of SAX. Unfortunately I don’t know exactly when this change arrived as I don’t have any devices running Android > 4.4.4 and < 6.0.1.

    Android 4.1.2:

    performance comparison of xml parsing methods on Android 4.1.2

    Android 4.4.4:

    performance comparison of xml parsing methods on Android 4.4.4

    Android 6.0.1:

    performance comparison of xml parsing methods on Android 6.0.1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read many articles about XML parsing in Android. However, all of them
I have to read/write an XML file that stores its data as bit masked
I have a really simple XML file that I'm trying to read, but I
I have an xml file(from federal government's data.gov) which I'm trying to read with
I have an XML file as follows, and I'm trying to read the content
I have a simple question about sending a file (XML file) from my webapp
I have an XML file that is approximately 12mb which has about 16000 product's.
I am trying to have PHP read an XML file and then convert it
I have read an xml file into a char [] and am trying to
My question is as follows: I have to read a big XML file, 50

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.