elegos wrote: > I'm new to the Java programming (see the other messages), I come from > PHP for handling XML files. I usually use SimpleXML, a very simple > class to manage this type of files. Here is an example: > > $xml = new simplexml_load("http://mycoolsite.com/file.xml"); > foreach($xml->contents as $entity => $value) > echo "$entity: $value"; > > Ok, now tell me why I should handle XML files like THIS: > http://www.anddev.org/parsing_xml_from_the_net_-_using_the_saxparser-t353.html
1. Because it is part of standard Java. 2. Because you are no longer writing PHP to run on a 2009 Web server, with quad-core-plus processors and multiple GB of RAM; rather, you are writing Java for a phone whose hardware specifications most closely resemble a Web server from 1996. Having owned and operated a Web server in 1996, I speak from personal experience... Parsing an XML file fully into RAM can be done (using the DOM parser), but it is expensive in terms of CPU time and RAM, neither of which exist in abundance on a phone. The better-performing solutions, SAX and XPP, are event-based, meaning you only hold onto in RAM the bits and pieces you actually need, and Java can accelerate past chunks of the file that you do not need. Of the three (DOM, SAX, XPP), XPP is probably the least used, since it is not part of standard Java, though it is available in the Android SDK via a third-party library. Hence, the other two will be more widely documented, with samples and tutorials and books and whatnot. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Training in Germany, 18-22 January 2010: http://bignerdranch.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---