[android-developers] Re: DOM, SAX or XMLPullParser ? Any suggestions ?

2010-02-09 Thread dontcare
Have you looked at vtd-xml? according to teh web site, it is 10x
faster than DOM, 2x faster than SAX, and natively supports XPath, and
is a lot more memory efficient than SAX

http://vtd-xml.sf.net

On Feb 7, 3:08 am, "Emre A. Yavuz"  wrote:
> Thanks for all the responses ...
>
> Cheers,
>
> Emre
>
>
>
>
>
> > Date: Sat, 6 Feb 2010 11:18:44 -0800
> > Subject: [android-developers] Re: DOM, SAX or XMLPullParser ? Any 
> > suggestions ?
> > From: jotobje...@gmail.com
> > To: android-developers@googlegroups.com
>
> > On Feb 5, 5:45 am, "Emre A. Yavuz"  wrote:
> > > Hi,
>
> > > We need to convert XML messages to a stream or string which can then be 
> > > sent via sockets.
>
> > You can read one XML input with XmlPullParser (or DOM or SAX) and
> > write it at the same time to another stream with XMLSerializer - see
> > XmlPullParserFactory.newSerializer().
>
> > Regarding your other question, your code controls the parsing thread
> > with XmlPullParser, but with SAX the parser controls the thread while
> > your DocumentHandler waits for callbacks.
>
> > --
> > 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
>
> _
> Introducing Windows® phone.http://go.microsoft.com/?linkid=9708122- Hide 
> quoted text -
>
> - Show quoted text -

-- 
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


RE: [android-developers] Re: DOM, SAX or XMLPullParser ? Any suggestions ?

2010-02-07 Thread Emre A. Yavuz

 

Thanks for all the responses ...

 

Cheers,

 

Emre
 
> Date: Sat, 6 Feb 2010 11:18:44 -0800
> Subject: [android-developers] Re: DOM, SAX or XMLPullParser ? Any suggestions 
> ?
> From: jotobje...@gmail.com
> To: android-developers@googlegroups.com
> 
> On Feb 5, 5:45 am, "Emre A. Yavuz"  wrote:
> > Hi,
> >
> > We need to convert XML messages to a stream or string which can then be 
> > sent via sockets.
> 
> You can read one XML input with XmlPullParser (or DOM or SAX) and
> write it at the same time to another stream with XMLSerializer - see
> XmlPullParserFactory.newSerializer().
> 
> Regarding your other question, your code controls the parsing thread
> with XmlPullParser, but with SAX the parser controls the thread while
> your DocumentHandler waits for callbacks.
> 
> -- 
> 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
  
_
Introducing Windows® phone.
http://go.microsoft.com/?linkid=9708122

-- 
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

[android-developers] Re: DOM, SAX or XMLPullParser ? Any suggestions ?

2010-02-06 Thread jotobjects
On Feb 5, 5:45 am, "Emre A. Yavuz"  wrote:
> Hi,
>
> We need to convert XML messages to a stream or string which can then be sent 
> via sockets.

You can read one XML input with XmlPullParser (or DOM or SAX) and
write it at the same time to another stream with XMLSerializer  - see
XmlPullParserFactory.newSerializer().

Regarding your other question, your code controls the parsing thread
with XmlPullParser, but with SAX the parser controls the thread while
your DocumentHandler waits for callbacks.

-- 
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


[android-developers] Re: DOM, SAX or XMLPullParser ? Any suggestions ?

2010-02-06 Thread Sam Dutton
Bear in mind that speed (DOM v SAX) may not be much of an issue for
parsing smaller amounts of XML, or where for some reason you can't use
the parsed data until you've parsed the entire XML document anyway:
SAX shines where you can (and need to) use data (e.g. to update a GUI)
as soon as it's parsed. The speed bottleneck is often somewhere else,
such as the HTTP request/response cycle time, rendering or other
processing.

Likewise for DOM: DOM documents will take more memory than using SAX,
but this may not be a problem if you're careful.

A really simple DOM utility library would be useful, e.g. 'get me
value of the attribute foo on first child blah element'.

Sam


It's more the memory taken by DOM documents.

On Feb 5, 1:45 pm, "Emre A. Yavuz"  wrote:
> Hi,
>
> We need to convert XML messages to a stream or string which can then be sent 
> via sockets. However, Android does not support the standard javax classes 
> that are used to convert a DOM XML object to a stream. Besides, as far as I 
> know, DOM parser reads all of the XML document into the memory before 
> allowing to use the DOM APIs to transverse the XML tree in order to retrieve 
> the data you want. This may be simpler than the SAX-based implementations, 
> however DOM generally consumes more memory as everything is read into the 
> memory first although this won't effect the performance on a mobile device 
> much, unless the size of the XML document is large.
>
> On the other hand, using SAX or XML pull parser may be better options due to 
> the extra utilities provided for them. XML PullParser works similarly to StAX 
> which is also not supported by the Android platform. This class seems to 
> allow your application code to pull or seek events from the parser, as 
> opposed to the SAX parser which automatically pushes events to the handler. 
> You can also set a flag to identify when you reach the end of the content 
> that you are interested in. This lets you halt the reading of the XML 
> document early, as you know that the code will not care about the rest of the 
> document. This can be very useful, especially if you only need a small 
> portion of the XML document being accessed. That means you can reduce the 
> parsing time by stopping the parsing as soon as possible especially when the 
> size of the XML document is large.
>
> I was wondering whether anybody, who has experience using the XmlPullParser 
> class or others on the Android platform, has anything to say about its 
> efficiency, well-known problems if any, suggestions for a better alternative, 
> links for sample code etc.
>
> Cheers,
>
> Emre
>
> _

-- 
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


Re: [android-developers] Re: DOM, SAX or XMLPullParser ? Any suggestions ?

2010-02-05 Thread Carmen Delessio
This article does the comparison for performance. (Perhaps the link Mark was
referring to)
http://www.developer.com/xml/article.php/10929_3824221_2/Android-XML-Parser-Performance.htm

*Conclusion:*
*When Parsing on the Handset is Required: Stick with SAX*

*When parsing of XML on the Android handset is required, I would recommend
using the SAX parser, especially where the file sizes are relatively small.*
The article does not take into consideration some of the things mentioned in
this thread: "binary XML" and code readability.
Carmen
-- 
Carmen
http://www.twitter.com/CarmenDelessio
http://www.talkingandroid.com
http://www.facebook.com/BFFPhoto
http://www.twitter.com/DroidDrop


On Fri, Feb 5, 2010 at 5:18 PM, Emre A. Yavuz  wrote:

>  Thanks to you both ...
>
> Cheers,
>
> Emre
>
> > Date: Fri, 5 Feb 2010 09:23:54 -0800
> > Subject: [android-developers] Re: DOM, SAX or XMLPullParser ? Any
> suggestions ?
> > From: rbgrn@gmail.com
> > To: android-developers@googlegroups.com
>
> >
> > I've used all 3. Which one to use depends a lot on what you need to
> > do. SAX is def quick but doesn't necessarily have the easiest
> > interface to use. I use it and it's not that hard but I've found that
> > for really simple parsing, PullParser is a little bit more straight-
> > forward. With either of the two, you end up with basically the same
> > structure of code, but PP code is a little easier to read IMO.
> >
> > DOM is good for more complex stuff. You can walk through the
> > hierarchy and pull out just the parts you want.
> >
> > On Feb 5, 8:01 am, "Mark Murphy"  wrote:
> > > > I was wondering whether anybody, who has experience using the
> > > > XmlPullParser class or others on the Android platform, has anything
> to say
> > > > about its efficiency, well-known problems if any, suggestions for a
> better
> > > > alternative, links for sample code etc.
> > >
> > > I saw one study (sorry, don't have the link handy) that indicated that
> on
> > > Android SAX and XPP were roughly equivalent in terms of performance.
> XPP
> > > really shines with the "binary XML" that resources get turned into as
> part
> > > of the APK packaging process. DOM, as you indicated, is much slower,
> > > though it has its uses.
> > >
> > > There is a link to some sample code on the main xmlpull.org site:
> > >
> > > http://xmlpull.org/v1/download/unpacked/doc/quick_intro.html
> > >
> > > --
> > > Mark Murphy (a Commons Guy)http://commonsware.com
> > > Android App Developer Books:http://commonsware.com/books.html
> >
> > --
> > 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
>
> --
> All your Hotmail contacts on your phone. Try it 
> now.<http://go.microsoft.com/?linkid=9708118>
>
> --
> 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
>

-- 
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

RE: [android-developers] Re: DOM, SAX or XMLPullParser ? Any suggestions ?

2010-02-05 Thread Emre A. Yavuz

Thanks to you both ...

 

Cheers,

 

Emre
 
> Date: Fri, 5 Feb 2010 09:23:54 -0800
> Subject: [android-developers] Re: DOM, SAX or XMLPullParser ? Any suggestions 
> ?
> From: rbgrn@gmail.com
> To: android-developers@googlegroups.com
> 
> I've used all 3. Which one to use depends a lot on what you need to
> do. SAX is def quick but doesn't necessarily have the easiest
> interface to use. I use it and it's not that hard but I've found that
> for really simple parsing, PullParser is a little bit more straight-
> forward. With either of the two, you end up with basically the same
> structure of code, but PP code is a little easier to read IMO.
> 
> DOM is good for more complex stuff. You can walk through the
> hierarchy and pull out just the parts you want.
> 
> On Feb 5, 8:01 am, "Mark Murphy"  wrote:
> > > I was wondering whether anybody, who has experience using the
> > > XmlPullParser class or others on the Android platform, has anything to say
> > > about its efficiency, well-known problems if any, suggestions for a better
> > > alternative, links for sample code etc.
> >
> > I saw one study (sorry, don't have the link handy) that indicated that on
> > Android SAX and XPP were roughly equivalent in terms of performance. XPP
> > really shines with the "binary XML" that resources get turned into as part
> > of the APK packaging process. DOM, as you indicated, is much slower,
> > though it has its uses.
> >
> > There is a link to some sample code on the main xmlpull.org site:
> >
> > http://xmlpull.org/v1/download/unpacked/doc/quick_intro.html
> >
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com
> > Android App Developer Books:http://commonsware.com/books.html
> 
> -- 
> 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
  
_
Introducing Windows® phone.
http://go.microsoft.com/?linkid=9708122

-- 
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

[android-developers] Re: DOM, SAX or XMLPullParser ? Any suggestions ?

2010-02-05 Thread Robert Green
I've used all 3.  Which one to use depends a lot on what you need to
do.  SAX is def quick but doesn't necessarily have the easiest
interface to use.  I use it and it's not that hard but I've found that
for really simple parsing, PullParser is a little bit more straight-
forward.  With either of the two, you end up with basically the same
structure of code, but PP code is a little easier to read IMO.

DOM is good for more complex stuff.  You can walk through the
hierarchy and pull out just the parts you want.

On Feb 5, 8:01 am, "Mark Murphy"  wrote:
> > I was wondering whether anybody, who has experience using the
> > XmlPullParser class or others on the Android platform, has anything to say
> > about its efficiency, well-known problems if any, suggestions for a better
> > alternative, links for sample code etc.
>
> I saw one study (sorry, don't have the link handy) that indicated that on
> Android SAX and XPP were roughly equivalent in terms of performance. XPP
> really shines with the "binary XML" that resources get turned into as part
> of the APK packaging process. DOM, as you indicated, is much slower,
> though it has its uses.
>
> There is a link to some sample code on the main xmlpull.org site:
>
> http://xmlpull.org/v1/download/unpacked/doc/quick_intro.html
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> Android App Developer Books:http://commonsware.com/books.html

-- 
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