Ksoap2-Android的解析器为我的Web服务请求一个XML节点
问题描述:
的Android库。我当面对我的web服务将返回一个节点一个问题:Ksoap2-Android的解析器为我的Web服务请求一个XML节点
<tag1> ... </tag1>
<tag1> ... </tag1>
<tag1> ... </tag1>
<tag1> ... </tag1>
有一些例子如何,如果有一个会导致一个节点解析:
http://seesharpgears.blogspot.com/2010/10/web-service-that-returns-array-of.html
但在我的情况下,我找不到那些好东西。也许有人可以分享一些想法,可以帮助我。
谢谢。
答
你尝试过这样的事情:
SoapObject soapObject = envelope.getResponse();
for (int i = 0; i < soapObject.getPropertyCount(); i++) {
SoapObject resource = (SoapObject) response.getProperty(i);
String uri = resource.getAttribute("uri").toString();
String mimeType = resource.getAttribute("mimeType").toString();
String size = resource.getAttribute("size").toString();
String localURI = resource.getAttribute("localURI").toString();
//do stuff
}
注:这是我使用从资源
这个例子遍历响应SOAP对象的标签列表获取属性的例子,得到每个标记的3个已知属性,参见下文实例响应:
<resources xmlns="http://www.example.com/">
<resource mimeType="text/xml" size="123456" uri="https://example.com/content/get.php?a123891" localURI="package.opf"/>
<resource mimeType="application/x-dtbncx+xml" size="123456" localURI="nav.ncx"/>
</resources>