ここにはデータがありません。その後、Pcode 0 を取得しましたが、ここでは Pcode 0 を取得できませんでした。私の意図は、Pcode 0 を取得し、「Not Data Here」メッセージを表示することです。xml でデータ解析を使用していますが、適切に解析できませんでした。解析エラーでエラーが発生しましたが、エラーを実行している場所で検索を取得できませんでした。これが私のコードです:
Log.d("user id is ", userId + "!");
String input = String.format("<Es_Request><Data><UserId>%s</UserId></Data></Es_Request>", userId);
String response = HttpPostRetreiver .retriver(Url.url_getting_assignment, input, GradeAssignmentActivity.this);
if (response != null) {
esResponse = XmlParser.parseAssignmentProfessorResponse(response);
Log.d("TAG", "Checking Value="+ esResponse.getResponseCode().getpCode());
if (esResponse.getResponseCode().getpCode().equalsIgnoreCase("1")) {
assignmentDataInfo = esResponse .getAssignmentListData().getAssignmentDataInfo();
int size = assignmentDataInfo.size();
int i = 0;
for (; i < size; i++) {
EduInterface.assignmetIdArrayList.add(assignmentDataInfo.get(i).getAssignmentId());
EduInterface.assignmetNameArrayList.add(assignmentDataInfo.get(i).getAssignmentName());
}
} else {
test = 1;
Log.d("else", "Not data Here");
}
}
} else {
Log.d("TAG", "Error in Webservice");
}
} catch (Exception e) {
Log.e("Grade Assignment class", e.toString() + "");
}
最初のユーザー ID は 5 です。その後、Grade Assignemt Class errorというエラーが発生しました。私は問題の解析をしてきました
入力文字列: Es_Request><Data><UserId>913</UserId></Data></Es_Request>
応答文字列:
<?xml version="1.0" encoding="utf-8"?><Es_Response><Es_Session_Id></Es_Session_Id>
<Bpn_Request_Id></Bpn_Request_Id><Response_Code><Pcode>0</Pcode><Scode>Unsuccessful</Scode></Response_Code><Data><message>Assignments not found for Professor & CourseId.</message></Data></Es_Response>
これが私のハンドラークラスです:
@Override
public void startElement(String uri, String localName, String qName,
Attributes atts) throws SAXException {
content = new StringBuilder();
if (localName.equalsIgnoreCase("Data")) {
assignmentListData=new AssignmentListData();
} else if (localName.equalsIgnoreCase("assignments")) {
assignmentItems = new AssignmentItems();
}
else if (localName.equalsIgnoreCase("Es_Response")) {
esResponse=new EsResponse();
} else if (localName.equalsIgnoreCase("Response_Code")) {
responseCode=new ResponseCode();
}
}
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
if (localName.equalsIgnoreCase("Pcode")) {
responseCode.setpCode(content.toString());
Log.d("TAG", "Pcode Value->"+content.toString());
}
else if (localName.equalsIgnoreCase("Response_Code")) {
esResponse.setResponseCode(responseCode);
}
else if (localName.equalsIgnoreCase("AssignmentId")) {
assignmentItems.setAssignmentId(content.toString());
}
else if (localName.equalsIgnoreCase("AssignmentName")) {
assignmentItems.setAssignmentName(content.toString());
}
else if (localName.equalsIgnoreCase("Assignments")) {
assignmentDataInfo.add(assignmentItems);
}
else if (localName.equalsIgnoreCase("Data")) {
assignmentListData.setAssignmentDataInfo(assignmentDataInfo);
}
else if (localName.equalsIgnoreCase("Es_Response")) {
esResponse.setAssignmentListData(assignmentListData);
}
}
私はこれをlogcatしました:
04-30 19:25:51.378: D/getting course list->(1598): Line 322---RESPONSE<?xml version="1.0" encoding="utf-8"?><Es_Response><Es_Session_Id></Es_Session_Id>
04-30 19:25:51.378: D/getting course list->(1598): <Bpn_Request_Id></Bpn_Request_Id><userIDName>913</userIDName><schoolID>1</schoolID><CourseID>977</CourseID><Response_Code><Pcode>0</Pcode><Scode>Unsuccessful</Scode><Test>977</Test><ROLE ID>4</ROLE ID></Response_Code><Data><message>Assignments not found for Professor & CourseId.</message></Data></Es_Response>
04-30 19:25:51.378: D/user id is(1598): 913
04-30 19:25:51.378: D/school id is(1598): 1
04-30 19:25:51.388: D/TAG(1598): Pcode Value->0
04-30 19:25:51.398: W/System.err(1598): org.apache.harmony.xml.ExpatParser$ParseException: At line 2, column 189: not well-formed (invalid token)
04-30 19:25:51.398: W/System.err(1598): at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:499)
04-30 19:25:51.398: W/System.err(1598): at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:484)
04-30 19:25:51.409: W/System.err(1598): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:309)
04-30 19:25:51.409: W/System.err(1598): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:267)
04-30 19:25:51.409: W/System.err(1598): at sdei.edustatusnew.services.XmlParser.parseAssignmentProfessorResponse(XmlParser.java:840)
04-30 19:25:51.409: W/System.err(1598): at sdei.edustatusnew.gradebook.GradeAssignmentActivity$GetDataTask.doInBackground(GradeAssignmentActivity.java:326)
04-30 19:25:51.409: W/System.err(1598): at sdei.edustatusnew.gradebook.GradeAssignmentActivity$GetDataTask.doInBackground(GradeAssignmentActivity.java:1)
04-30 19:25:51.427: W/Trace(1598): Unexpected value from nativeGetEnabledTags: 0
04-30 19:25:51.427: W/Trace(1598): Unexpected value from nativeGetEnabledTags: 0
04-30 19:25:51.438: W/Trace(1598): Unexpected value from nativeGetEnabledTags: 0
04-30 19:25:51.438: W/Trace(1598): Unexpected value from nativeGetEnabledTags: 0
04-30 19:25:51.468: W/System.err(1598): at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-30 19:25:51.478: W/System.err(1598): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-30 19:25:51.478: W/System.err(1598): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
04-30 19:25:51.488: W/System.err(1598): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-30 19:25:51.488: W/System.err(1598): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-30 19:25:51.488: W/System.err(1598): at java.lang.Thread.run(Thread.java:856)
04-30 19:25:51.488: E/Grade Assignment class(1598): java.lang.NullPointerException
私のコードのエラーは何ですか。前もって感謝します。