You may want to ask this on stackoverflow, but, more importantly, DOM takes up more memory for the XML file, so why use that on a mobile device with less memory?
Do you have a business need to prefer DOM over just processing the file? If not, then you may want to rethink what you are asking about. On Sun, Jan 15, 2012 at 11:25 AM, John Goche <[email protected]>wrote: > > Hello, > > I have been reading up on how to use XML from within android. Apparently > the interfaces are SAX which allows callbacks to be called when each > element > is processed, DOM which allows in-memory tree representations of XML, JAXP > which can be used to validate XML given an XML Schema, and JAXB which is > available but takes up 8MB or so of space and would be used to convert back > and forth between XML and some annotated Java classes automatically at the > aforementioned disk storage price. Apparently JAXB used to be used to > validate > but since JAXB 2.0 that function has been delegate to JAXB. Apparently > there > are three DOM levels, and Android's JDK supports level 2: > > http://developer.android.com/reference/org/w3c/dom/package-summary.html > > plus the load/store facilities available in DOM Level 3 which AFAIK are > used to > serialize/deserialize XML instances to and from memory? > > http://developer.android.com/reference/org/w3c/dom/ls/package-summary.html > > Then there are a variety of other XML APIs which do not come with Android > the > most nototrious being xerces from apache foundation which used to not be > bundled with jdk. Since jdk 5 it is, but apparently people don't use it > because > java has its own DOM API. Why would you want to use it when java bundles > a DOM API already. What more can xerces offer? And what more does the > full xerces implementation offer if you were to add the xerces jar file to > your APK? > > Anyways, in the end I decided I am going to use DOM to read my files and > simply > throw an exception if what I receive does not conform to what I expect. I > also want > to build my XML files with DOM prior to sending the XML over a network. > > I'm not clear on the following: where do I find good docs on DOM for > Android. Is > the API all there is available? Several books such as the following: > > > http://www.amazon.com/Java-XML-Brett-McLaughlin/dp/059610149X/ref=sr_1_1?ie=UTF8&qid=1326644460&sr=8-1 > > seem to be somewhat obsolete and document xerces or obsolete APIs/issues > (such as org.apache.xerces.parsers.DOMParser > which now seems to be replaced with: > > import javax.xml.parsers.DocumentBuilderFactory; > import javax.xml.parsers.DocumentBuilder; > > Anyways, any pointers to tutorials on using DOM on Android to process and > build XML using DOM welcome. > One useful link I found was the following: > http://www.mkyong.com/java/how-to-read-xml-file-in-java-dom-parser/ > > Thanks for your input, > > John Goche > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- "I know that you believe you understand what you think I said, but I'm not sure you realize that what you heard is not what I meant." - Robert McCloskey -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

