简体   繁体   English

在Android中读取xml的最佳方法是什么?

[英]What's the best way to read xml in android?

Hi I've an android app which uses an XML file to render its User Interface,And here is the xml 嗨,我有一个使用XML文件呈现其用户界面的android应用,这是xml

<?xml version="1.0" encoding="utf-8"?>
<questions>
<question id="1" label="Name" type="text"></question>
<question id="2" label="Gender" type="select" options="Male,Female,Transgender"></question>
<question id="3" label="Age" type="text"></question>
<question id="4" label="city" type="select" options="Banglore,Hyderabad,Chennai"></question>
</questions>

I am using DOM parser to read xml and I am getting the inputstream using url.openconnection().getInputstream() method.But I want the xml file to be included in my android project folder and use it.How would I go about that ?? 我正在使用DOM解析器读取xml,并使用url.openconnection()。getInputstream()方法获取输入流,但我希望将xml文件包含在我的android项目文件夹中并使用它。 ?? so what are the other ways to get the InputStream ?? 那么还有什么其他方法可以获取InputStream呢?

如果将文件放在资产文件夹中,则可以使用AssetManager获取输入流。

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

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