简体   繁体   中英

Can i parse a binary XML file ( in res/xml ) with a SAX parser

To clarify my question :-)

I want to have the best of both worlds.

  1. The speed of having a compressed xml file
  2. The speed of the SAX parser ( over a XmlResourceParser that is normally used with binary files )

Most important question is: Can this be done?

Closest i came to the solution is.

  • OR open a raw resource ( not binary formatted )
  • OR parse a binary xml file with a XmlResourceParser

I hope someone can help me get a bit further in this situation.

Edit: link to reflect SAX-parser speed

SAX parser is not more efficient than XmlResourceParser for XML in raw resource. Just use XmlResourceParser.

You can place your xml file assets folder and you can use Sax parser

InputStream xmlFileStram = getAssets().open(filePath); // this gives the file in your asset folder
XmlHandler xmlHandler = new XmlHandler(activity);
SAXParserFactory.newInstance().newSAXParser().parse(xmlFileStram, xmlHandler);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM