阅读从资源的XML文件 [英] Reading a XML file from resources
本文介绍了阅读从资源的XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我需要在Android SDK解析XML文件。
我如何从资源读取XML文件路径?
XML包含:
<图书>
<第二章>
&所述否GT; 1< / NO>
<文字>我的主< /文字>
< /章>
<第二章>
&所述否GT; 1< / NO>
<文字>我的主< /文字>
< /章>
< /图书>
解决方案
把它放在 your_project_root \水库\ XML \
文件夹。然后你就可以打开它:
资源资源= activity.getResources();
XmlResourceParser XRP = res.getXml(R.xml.your_resId);
有关于如何使用的例子 XmlResourceParser
这里:
<一个href="http://android-er.blogspot.com/2010/04/read-xml-resources-in-android-using.html">http://android-er.blogspot.com/2010/04/read-xml-resources-in-android-using.html
I have a XML file that I need to parse in the Android SDK.
How can I read the XML file path from resources?
The XML contains:
<Book>
<Chapter>
<NO> 1 </NO>
<Text> My Lord </Text>
</Chapter>
<Chapter>
<NO> 1 </NO>
<Text> My Lord </Text>
</Chapter>
</Book>
解决方案
Put it under your_project_root\res\xml\
folder. Then you can open it with:
Resources res = activity.getResources();
XmlResourceParser xrp = res.getXml(R.xml.your_resId);
There is an example on how to use XmlResourceParser
here:
http://android-er.blogspot.com/2010/04/read-xml-resources-in-android-using.html
这篇关于阅读从资源的XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文