How can i parse a local XML file in the assets folder using pull parser? I can't get pull parser to work. It always throws an io exception. I think I can't get the path to the file, or connecting to the file.
相关问题
- How can I create this custom Bottom Navigation on
- Illegal to have multiple roots (start tag in epilo
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Creating XML Elements without namespace declaratio
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Get Attribute Value From Simple XML Using JQuery /
mixm,
I was toying with various ways to load a local file from both 'assets' and 'res', but to answer your question as asked (as no one else seems to have):
First, either make sure your XML is valid before testing or turn off validation, this is how you can do that and instantiate a pull parser at the same time:
Then open the xml file and set as input to your pull parser:
Now setup your pull loop (or other, depends on whether you want to do deferred pulling or not, that's your design decisions:
Note the
myxml.getEventType()
, you need to do this to get the parse going and handle what type events you are pulling. Note: catch blocks omitted for readability.Tested the above on 2.1, hope it helps -Frank