谁能告诉我如何解析以下 Xml.xml 文件?我得到以下 xml 作为 HttpGet 方法的响应。我可以以字符串形式存储这个 xml。
<?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>
我想解析的属性outline
。我也想展示的价值text
在列表视图中。请给我提供示例代码。
提前致谢 ...!!!
如果您使用 SAXParser,请参阅 sax 解析器实现的示例:
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
在这里您可以检查属性及其值
if(localName.equals("outline"))
String txtValue= attributes.getValue("text");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)