David,

XML parsing options available in Android were discussed here within the last month.

I recall that Dianne Hackborn posted some interesting performance comparisons.

Try finding that thread, I think it should be quite interesting w.r.t. to your question.

Android also includes the ability to parse XML precompiled into some sort of binary format, this is faster than parsing text. This is how layouts and other platform-specific resources are packaged in the .apk. Perhaps there is a way to use binary XML for your own files as well.

You can put any file you want into the asset folder, and have access to it at runtime. There is no reason it can't be a file with persisted objects.

So there are many good ways to skin this particular cat.

-- Kostya

16.08.2010 20:30, DanH пишет:
Comparing DOM and SAX is like comparing apples and bullfrogs.  They do
two largely different things.  DOM reads in an entire XML document and
stores it as Java objects so that you can quickly reference parts of
it without knowing (or at least having to specify) in advance what
parts you're interested in.  SAX (rapidly) parses an XML file but
leaves it up to you to know (and write code for) which parts to save
as it speeds by.

A new, "middle of the road" technology is "pull parsing", which uses a
SAX-like scanner but lets you specify in advance which elements you
want saved.

Another option is to use a lighter weight markup language.  JSON is
much more compact, parses much faster, and is generally easier to deal
with.

If you want to "cache" an XML file it would make more sense to cache
the parsed information vs the original file, if parsing speed is
already an issue.  There are a dozen different ways to cache the
parsed information, depending on its size and structure.

On Aug 16, 9:02 am, Davide<d...@vide.bz>  wrote:
Hi,

I have seen that xml parsing is very slow. Using sax would be better,
but benchmark show that sax work only 30%
faster as dom. Is right? Is faster if I construct a "DOM" using sax?

To reduce time i like to cache xml file. Caching it as xml is not a
good idea because the parsing time is there again
the secondo time.

Should I use sqllite? Is faster? Is an idea to use an
ObjectOutputStream? Can I put in asset a file maked by
ObjectOutputStream
or the serialized objects can be different in different mobile hardware?

--
   _|  _.    o  _|  _
  (_| (_| \/ | (_| (/_


--
Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to