1
我是xml概念的新手。我從.net Web服務接收數據。此Web服務返回數據集作爲結果。我使用soap對象接收這個數據集結果。它以XML格式返回。我無法從返回的結果中檢索數據。如何從android中的.NET web服務soap對象解析XML數據?
輸出爲Web服務是這樣的:
GETRESULTSResponse{GETRESULTSResult=anyType{Users=anyType{Table1=anyType{StudentID=713; RegisterNumber=2913402; StudentName=KARTHIK M; Gender=Male; CourseID=6; BranchID=27; BatchID=18; RollNumber=10SLEC603; }; }; }; }
我想每一個元素的數據。我不知道如何解析它。請幫助我。
這是我的代碼片段:
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, METHOD_NAME1);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
PropertyInfo pi = new PropertyInfo();
pi.setName("strSQL");
pi.setValue(ConstantValues.STUDENT_DETAILS);
pi.setType(ArrayList.class);
request.addProperty(pi);
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransportSE = new HttpTransportSE(SOAP_ADDRESS);
SoapObject response = null;
httpTransportSE.call(SOAP_ACTION1, envelope);
response = (SoapObject)envelope.bodyIn;
String xml = response.toString();
Document doc = XMLfunctions.XMLfromString(xml);
int numResults = XMLfunctions.numResults(doc);
if(totalCount > 0){
NodeList nodes = doc.getElementsByTagName("Table1");
for (int i = 0; i < nodes.getLength(); i++) {
Element e = (Element)nodes.item(i);
String studentId = XMLfunctions.getValue(e, "StudentID");
String regNo = XMLfunctions.getValue(e, "RegisterNumber");
String stuName = XMLfunctions.getValue(e, "StudentName");
String gender = XMLfunctions.getValue(e, "Gender");
}
}
我嘗試使用此代碼來分析數據。但我無法解析它。請給我提供一個簡單的方法來解析SOAP對象響應中的XML數據,我從.Net webservice數據集獲取它。
先謝謝您。
我會a)不返回數據集b)使用[Restfull](http://www.ibm.com/developerworks/webservices/library/ws-restful/)web服務 – I4V 2013-04-11 09:01:03