In my Android app I need to extract data from a xml file (the file will have less than 2000 lines). I have no experience with XML parsing, so I don’t know what the best approach is. DOM parser is perhaps not a good option, because I am on a mobile device. On the other hand with SAX I would probably end with more complicated code. What would you recommend?
Share
Depends on exactly what you want to extract, but for small enough documents I don’t think DOM is too bad, and it comes bundled with JDK (I think on android too). For ultimate convenience I would use JAXB, to bind to Java beans; it uses SAX parser by default and is more efficient than using DOM trees (as well as easier to use).
Otherwise I would look into pull parsers; android ships with xpp which is ok, but Woodstox is my favorite.