我是 Android 新手(移植 iOS/Objective C 应用程序),我必须读取 WebService 返回的 XML(在 JSON 中有一些节点)文件
响应如下所示:
<SOAP-ENV:Envelope><SOAP-ENV:Body><ns1:TPLoginResponse><TPLoginResult>[{"content": "some json content...."]</TPLoginResult></ns1:TPLoginResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
我怎样才能简单地获取 TPLoginResult 的内容?
我试过 :
httpTransport.call(SOAP_ACTION, envelope);
Object response = envelope.getResponse();
SoapObject SoapResponse = (SoapObject)envelope.bodyIn;
Log.e("Info", "response : " + SoapResponse.toString() ); // content is successfully received here
String SResponse = SoapResponse.toString();
Log.e("Info", "DocumentBuilderFactory" );
// parse the XML as a W3C Document
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
builderFactory.setNamespaceAware(true);
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document document = builder.parse( new InputSource(new StringReader(SResponse)) );
NodeList nList = document.getElementsByTagName("TPLoginResult");
Log.e("info","nList length : " + nList.getLength());
但我需要一个长度为 0 的 nList ...
我也试过:
NodeList nList = document.getElementsByTagName("ns1:TPLoginResponse");
但相同的 0 长度结果..
有什么建议么 ?