Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Android XML Parsing

Hi Guys

I have been using the getElementsByTagName to parse webservice XML in android and binding it to a tableview is very slow with around 44 rows. Is it because i am on an emulator and the emulator does things slower than the actual phone or am i missing something? like using xpath or json?

— asked April 17th 2010 by sanchit sharma
  • android
  • xml

2 Answers

  • I'd be quite keen to find the answer here!

    Im getting about 7 pieces of information from about 60 groups of information (In XML.. Cant remember wether there Elements or what not! :/)

    When I get the information I insert it into the database! Both on the iPhone and Android it takes at least 10-12 seconds to complete this! Although I can confirm that the XML page displays straight away when browsing it on a normal computer!

    — answered April 17th 2010 by Scott Robinson
  • While I can't give you definite, guaranteed test results to back this up, from my experience the XML parser in Titanium is slower than parsing JSON by a significant factor. I did some tests ages ago (back on SDK 1.7.5) and parsing an XML document took 2-3 times more on average, compared to a JSON document with exactly the same data in it. This was reading from files directly off the device.

    My advice is don't use XML data from any web service unless you absolutely must, and that applies to local XML files too if you can use a JSON alternative. If the web service you're accessing only supplies XML and is public, consider using the Titanium.Yahoo.YQL() methods to convert it to JSON on the fly.

    — answered March 18th 2012 by Boydlee Pollentine
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.