机器人:我们怎样才能得到属性的值从XML字符串 [英] Android: How we can get the value from attribute from xml string
本文介绍了机器人:我们怎样才能得到属性的值从XML字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能告诉我怎样才能解析下面的XML。我得到了下面的XML作为HTTPGET方法的响应。我可以存储该XML的字符串形式。
Can anybody tell me how we can parse the following Xml. I get the following xml as response of HttpGet method. I can be store this xml in the string form.
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1">
<head>
<status>200</status>
</head>
<body>
<outline type="text" text="General" guide_id="f1" is_default="true"/>
<outline type="text" text="Rock Stations" guide_id="f2"/>
<outline type="text" text="Rock Stations" guide_id="f3"/>
<outline type="text" text="Rock" guide_id="f4"/>
<outline type="text" text="Awdhesh" guide_id="f5"/>
</body>
</opml>
我想解析概述
的属性。而且我也想展示文本
的列表视图中的价值。请给我一个样品code。
I want to be parse the attribute of outline
. And I also want to show the value of text
in listview. Please provide me a sample code.
在此先感谢... !!!
Thanks in Advance ...!!!
推荐答案
如果您使用的是SAXParcer,看到萨克斯parcer实现的例子:
If you are using SAXParcer, see an example of sax parcer implementation:
的http://mobile.tutsplus.com/tutorials/android/android-sdk-build-a-simple-sax-parser/
请注意方法
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException
在这里你可以查看属性和值
here you can check attributes and their values
if(localName.equals("outline"))
String txtValue= attributes.getValue("text");
这篇关于机器人:我们怎样才能得到属性的值从XML字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文