原话题来自于CSDN问答频道,更多解决方案见:http://ask.csdn.net/questions/1442

原问题描述:

我需要把下面的 xml 解析 为输出:

 String id="3"    String name="str1"   String path="/mnt/sdcard/path2"   String type="2"   String desc="des3)"

在 android中如何实现呢?

<xmldump>  <mfs id="3" name="str1" path="/mnt/sdcard/path2" type="2" desc="des3)" />  <mfs id="1" name="st2" path="/mnt/sdcard/path1" type="2" desc="des2" />  <mfs id="2" name="stvr3" path="/mnt/sdcard/path3" type="2" desc="des1" /></xmldump>


解决方案:

请参考这个例子:

<?xml version="1.0" encoding="UTF-8"?><Personnel>  <Employee type="permanent">        <Name>Seagull</Name>        <Id>3674</Id>        <Age>34</Age>   </Employee>  <Employee type="contract">        <Name>Robin</Name>        <Id>3675</Id>        <Age>25</Age>    </Employee>  <Employee type="permanent">        <Name>Crow</Name>        <Id>3676</Id>        <Age>28</Age>    </Employee></Personnel>

从解析内容中创建一个 Employee对象的列表,然后再打印出来。输出结果如下:

Employee Details - Name:Seagull, Type:permanent, Id:3674, Age:34.Employee Details - Name:Robin, Type:contract, Id:3675, Age:25.Employee Details - Name:Crow, Type:permanent, Id:3676, Age:28.

http://www.java-samples.com/showtutorial.php?tutorialid=152

更多相关文章

  1. Android——build.prop 解析
  2. 源码解析Android中AsyncTask的工作原理
  3. 虚拟键盘弹出时挡住EditText的解决方案
  4. 解析Android消息处理机制:Handler/Thread/Looper & MessageQueue
  5. android 日志文件输出
  6. Android(安卓)Build 异常 -android.support.VERSION 冲突
  7. Android的WindowManager解析
  8. Android(安卓)SDK 源码解析项目
  9. Android通过http协议POST传输方式(输出流提交到服务端)

随机推荐

  1. java.lang.IllegalStateException: No ho
  2. Google cardBoard Android(安卓)API (八)
  3. 【Android】软键盘弹出button与edittext
  4. android之datepicker控件的用法
  5. Android虚拟导航键的显示隐藏实例
  6. Android快速开发(2)
  7. 集成easaui报错解决方案
  8. list滑动删除item
  9. Android腾讯微博客户端开发三:多账号管理
  10. http通信,Android(安卓)Gzip压缩解压