简体   繁体   English

我可以使用SAX解析器解析二进制XML文件(在res / xml中)吗?

[英]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 压缩的xml文件的速度
  2. The speed of the SAX parser ( over a XmlResourceParser that is normally used with binary files ) SAX解析器速度 (超过通常用于二进制文件的XmlResourceParser)

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 使用XmlResourceParser解析二进制xml文件

I hope someone can help me get a bit further in this situation. 我希望有人可以在这种情况下帮助我进一步发展。

Edit: link to reflect SAX-parser speed 编辑:链接以反映SAX分析器的速度

SAX parser is not more efficient than XmlResourceParser for XML in raw resource. SAX解析器超过XmlResourceParser更有效率的原料资源XML。 Just use XmlResourceParser. 只需使用XmlResourceParser。

You can place your xml file assets folder and you can use Sax parser 您可以放置​​xml文件资产文件夹,并且可以使用Sax解析器

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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