Re: [android-developers] Re: Easy and fast XML Parser?
On Tue, Jul 13, 2010 at 12:57 PM, Mark Murphy mmur...@commonsware.comwrote: Part of the build process converts ordinary XML into a binary XML format that is smaller and quicker to parse at runtime. Yeah, it's basically a pre-processed DOM (well enough of a DOM to directly do an XmlPullParser on top of). Plus it also has other advanced features and APIs for even faster attribute retrieval, compile-time type conversions, string pooling, etc. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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: Easy and fast XML Parser?
It should be noted that XML is really a pretty lousy language all around -- hard to code, slow/difficult to parse, bulky. For many purposes, if you have a choice, JSON is a better option if you need a human-readable notation, and there are any number of internal forms that would be better than XML if you don't need it to be human- readable/modifiable. I've not (yet) tried to comprehend Android's compiled XML -- is there any sort of reference for it somewhere? On Jul 13, 7:22 pm, Dianne Hackborn hack...@android.com wrote: On Tue, Jul 13, 2010 at 12:57 PM, Mark Murphy mmur...@commonsware.comwrote: Part of the build process converts ordinary XML into a binary XML format that is smaller and quicker to parse at runtime. Yeah, it's basically a pre-processed DOM (well enough of a DOM to directly do an XmlPullParser on top of). Plus it also has other advanced features and APIs for even faster attribute retrieval, compile-time type conversions, string pooling, etc. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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: Easy and fast XML Parser?
On Wed, Jul 14, 2010 at 1:45 PM, DanH danhi...@ieee.org wrote: It should be noted that XML is really a pretty lousy language all around -- hard to code, slow/difficult to parse, bulky. For many purposes, if you have a choice, JSON is a better option if you need a human-readable notation, and there are any number of internal forms that would be better than XML if you don't need it to be human- readable/modifiable. Well, whether XML is really a pretty lousy language is highly subjective. It depends a lot on what you need to do (I could go into detail in a separate thread). But I agree for many client-server applications, JSON is much easier. I've wound up writing several web services that supply the same data in either XML or JSON. -- 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: Easy and fast XML Parser?
On Wed, Jul 14, 2010 at 1:45 PM, DanH danhi...@ieee.org wrote: I've not (yet) tried to comprehend Android's compiled XML -- is there any sort of reference for it somewhere? Only the source: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=include/utils/ResourceTypes.h;h=b701ce74d627d52a968dae96f3c10ffbc26ac153;hb=HEAD#l478 -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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: Easy and fast XML Parser?
DOM consumes memory and creates load of object (for big XML files), but DOM is easy to work with. SAX is event driven, but programming modell is awkward. There is pull XML parser in android though - like SAX but you are in control. But usually you like to have you objects out of XML - so you will need kind of databinding tool (unfortunately there is not one in android) XStream is easy to use, but not really small. I decided to use JSON in my apps, and wrote small databinding library: http://github.com/ko5tik/jsonserializer It works well on even relatively big JSON files (highscore lists with 1000 entries ) On Jul 13, 4:42 am, Streets Of Boston flyingdutc...@gmail.com wrote: I myself use the android.sax.* classes and the org.xmlpull.v1.XmlPullParserFactory that's configured to use the org.xmlpull.v1.sax2.Driver class for the actual hard work. (I wrapped some extra classes of my own around these (android.sax.*) to better track the the current context (i.e. which element the pull- parser is currently handling) of the parsing) On Jul 12, 3:30 pm, Siva siva.d...@gmail.com wrote: Can anyone tell me the easy and fastest XML Parser? I need guide/sample code... please help me... -- 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: Easy and fast XML Parser?
I've had the best luck with SAX. It's the fastest I found and I use it in my application that handles very large XML files and it does the job very quickly. I think I saw a tutorial on anddev.org about how to implement SAX in your application, but any tutorial on the net (desktop or mobile - doesn't matter) will help. On Jul 12, 2:30 pm, Siva siva.d...@gmail.com wrote: Can anyone tell me the easy and fastest XML Parser? I need guide/sample code... please help me... -- 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: Easy and fast XML Parser?
The choice between SAX and DOM is partly one of simplicity vs speed/ compactness, and partly a matter of what sort of consumption model you have. If you're only going to scan through the XML once, and you know what data you want, and it's pretty well formed (you know precisely what order elements will be in, etc) then SAX is good. If you need to keep referring to the data, or you need to extract data from documents that may be a bit disordered (with elements in varying order, extraneous elements, etc) then DOM is a lot simpler. But, yes, DOM does take up a fair amount of storage -- no hard numbers but I'd guess easily 20-50 times the size of the XML file. On Jul 12, 6:51 pm, Indicator Veritatis mej1...@yahoo.com wrote: SAX is faster than DOM. Easier too, if you don't mind viewing everything as event driven. Rumor has it there is something faster, but I am not convinced it is anything more than rumor. But do a Google search xml parser sax dom faster and see if you think Piccolo or NanoXML are worth checking out. I would stick with SAX though, until these newer ones have been reviewed and proven not to have major omissions and bugs. Besides: SAX and DOM are already in Android. If you choose one of the others, even Apache's Betwixt or Xerces, you will have to include it as an extra Jar in your build. On Jul 12, 12:30 pm, Siva siva.d...@gmail.com wrote: Can anyone tell me the easy and fastest XML Parser? I need guide/sample code... please help me... -- 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: Easy and fast XML Parser?
As a very rough sketch, the performance you can expect is: SAX is 10-100x slower than XmlPullParser on a compiled XML resource. DOM is 10-100x slower than SAX. (XmlPullParser on a raw XML file is slower than SAX, but not an order of magnitude.) For some context on that, a significant amount of time was spent on optimizing XmlPullParser on a compiled XML resource since that is critical to things like app launch time (which involves parsing layout and other XML resources). The current performance of that is sufficient but, especially for low-end devices, a 10x slow-down would very seriously negatively impact UI performance. So: if you are parsing XML as part of UI interaction, an XmlPullParser on a compiled resource should be sufficient for relatively real-time performance (just parse directly and display). A SAX or XmlPullParser on a raw XML file is most likely going to be slow enough to warrant doing in another thread and showing the result to the user when done. The DOM parser is going to be significantly slower than that. Of course this all depends on exactly what you are doing and the work that is needed outside of the raw XML parsing. On Tue, Jul 13, 2010 at 9:31 AM, DanH danhi...@ieee.org wrote: The choice between SAX and DOM is partly one of simplicity vs speed/ compactness, and partly a matter of what sort of consumption model you have. If you're only going to scan through the XML once, and you know what data you want, and it's pretty well formed (you know precisely what order elements will be in, etc) then SAX is good. If you need to keep referring to the data, or you need to extract data from documents that may be a bit disordered (with elements in varying order, extraneous elements, etc) then DOM is a lot simpler. But, yes, DOM does take up a fair amount of storage -- no hard numbers but I'd guess easily 20-50 times the size of the XML file. On Jul 12, 6:51 pm, Indicator Veritatis mej1...@yahoo.com wrote: SAX is faster than DOM. Easier too, if you don't mind viewing everything as event driven. Rumor has it there is something faster, but I am not convinced it is anything more than rumor. But do a Google search xml parser sax dom faster and see if you think Piccolo or NanoXML are worth checking out. I would stick with SAX though, until these newer ones have been reviewed and proven not to have major omissions and bugs. Besides: SAX and DOM are already in Android. If you choose one of the others, even Apache's Betwixt or Xerces, you will have to include it as an extra Jar in your build. On Jul 12, 12:30 pm, Siva siva.d...@gmail.com wrote: Can anyone tell me the easy and fastest XML Parser? I need guide/sample code... please help me... -- 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.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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: Easy and fast XML Parser?
I did some research on the difference between SAX push/pull parsers. The consensus was that generally they are within an order of magnitude, the speed varies somewhat depending on the data, and that there is a factor of the preference for programming push vs pull. You noted that there is a marked difference, in favor of pull, for compiled XML resource. What does that mean and why would it make such a differnce? -- 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: Easy and fast XML Parser?
On Tue, Jul 13, 2010 at 3:27 PM, Frank Weiss fewe...@gmail.com wrote: You noted that there is a marked difference, in favor of pull, for compiled XML resource. What does that mean and why would it make such a differnce? A compiled XML resource is an Android resource that is in XML. Like, say, layouts. Or menus. Or preferences. Or some types of drawables, strings, arrays, dimensions, colors, etc. Part of the build process converts ordinary XML into a binary XML format that is smaller and quicker to parse at runtime. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android 2.2 Programming Books: http://commonsware.com/books -- 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: Easy and fast XML Parser?
Not super-fast, but javax.xml.parsers.DocumentBuilder.parse is simple to use. But of course one needs to know what to do with the parsed file afterwards. DocumentBuilder produces a org.w3c.dom.Document object which you then must navigate by working your way through the nodes or by using xpath statements. On Jul 12, 2:30 pm, Siva siva.d...@gmail.com wrote: Can anyone tell me the easy and fastest XML Parser? I need guide/sample code... please help me... -- 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: Easy and fast XML Parser?
SAX is faster than DOM. Easier too, if you don't mind viewing everything as event driven. Rumor has it there is something faster, but I am not convinced it is anything more than rumor. But do a Google search xml parser sax dom faster and see if you think Piccolo or NanoXML are worth checking out. I would stick with SAX though, until these newer ones have been reviewed and proven not to have major omissions and bugs. Besides: SAX and DOM are already in Android. If you choose one of the others, even Apache's Betwixt or Xerces, you will have to include it as an extra Jar in your build. On Jul 12, 12:30 pm, Siva siva.d...@gmail.com wrote: Can anyone tell me the easy and fastest XML Parser? I need guide/sample code... please help me... -- 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: Easy and fast XML Parser?
I myself use the android.sax.* classes and the org.xmlpull.v1.XmlPullParserFactory that's configured to use the org.xmlpull.v1.sax2.Driver class for the actual hard work. (I wrapped some extra classes of my own around these (android.sax.*) to better track the the current context (i.e. which element the pull- parser is currently handling) of the parsing) On Jul 12, 3:30 pm, Siva siva.d...@gmail.com wrote: Can anyone tell me the easy and fastest XML Parser? I need guide/sample code... please help me... -- 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