解析Android的本地XML文件文件、Android、XML

2023-09-12 07:46:50 作者:小冷血‰

我如何能解析我的本地XML文件位于我的Andr​​oid项目(内RES / XML文件夹),并希望得到该文件中的值。

How can I parse my local XML file located in my android project (inside res/XML folder) and want to get the values in that file.

推荐答案

要访问存储在 RES / XML XML资源,调用getResources().getXml()从任何活动或其他上下文。您需要提供给的getXML()的XML的ID来加载( R.xml.myfile )。

To access XML resources stored in res/xml, call getResources().getXml() from any Activity or other Context. You need to supply to getXml() the ID of the XML to load (R.xml.myfile).