【Bug记录】Anroid解析xml 出现unexpected token错误
2015-07-01 21:51
232 查看
现象:Android使用XmlPullParser解析xml输入流出现unexpected token错误
原因:使用的xml文件放在res中,使用getResources().openRawResource(R.xml.XXX)获取输入流,解析出现错误;后改将xml放在assets中,换用getResources().getAssets().open("xxx.xml")方法获取stream,问题解决。
分析:百度到一分析:
Where do you store your xml file? In "res" folder. You should store it in "assets". Res-solution is not working because of specific of the "res" folder and it's presentation in the apk. Move your file to the "assets" and you'll see that everything is working. Use the following code for creating InputSource:
getAssets().open("yourfilename.xml")
相关文章推荐
- BUG记录——解析程序包出现错误
- 弱智问题导致context.xml解析错误,特记录
- 记录tomcat 8.0.26/27/28 容器bug,导致解析jsp错误
- 使用mybatis generator时出现xml解析错误:XML Parser Errors occurred
- 安卓SAX解析XML出现二次解析-------矫正我们错误的认知
- xml解析出现的错误
- 用dom或者sax解析xml运行出现错误Content is not allowed in prol
- xml解析错误记录
- dom4j解析XML时出现"java.lang.noclassdeffounderror: org/jaxen/jaxenexception"错误
- 解析xml出现Can't create default XMLReader; is system property org.xml.sax.driver set?错误
- Firefox升级后出现“XML解析错误”错误的解决方法
- jdom解析xml文件出现的一些错误
- 调试.NET项目出现XML解析错误:未找到元素位置 1行 1列"
- dom4j解析XML时出现"java.lang.noclassdeffounderror: org/jaxen/jaxenexception"错误
- python Python 解析xml文件出现错误xml.parsers.expat.ExpatError: unknown encoding 的解决
- sax解析xml运行出现错误
- 今天用PHP解析xml时出现如下错误:php Fatal error: Class 'DOMDocument' not found。 环境:CentOS 5.5; PHP 5.3.8 解决方法:
- 使用SDL2出现 “error LNK2019: 无法解析的外部符号 _SDL_main,该符号在函数 _main 中被引用” 时的可能错误记录
- 关于list转json出现无法显示xml(XML解析错误:未组织好)
- IE Bug 1 - 错误识别出现在javascript脚本中的字符串,导致HTML标签解析错误