我是 xml 概念的新手。我从 .net 网络服务接收数据。作为结果,此 Web 服务返回数据集。我使用肥皂对象接收此数据集结果。它以 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");
}
}
我尝试使用此代码解析数据。但我无法解析它。请为我提供简单的方法来解析我从.Net webservice 数据集获得的soap 对象响应中的xml 数据。
先感谢您。