android端pull解析xml格式string对象报错,求解!!

wangwanghuasheng 2013-01-19 10:15:37


//服务器端servlet发送xml格式的字符串result
String result = baseResBO.getclassifyresource(grade, subject, type, term);//返回一个xml格式字符串
response.getWriter().print(result);

//Android端
String result = null;
HttpPost httpRequest = new HttpPost(BASE_RES_URL);
try {
httpRequest.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try {
HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest);
result = EntityUtils.toString(httpResponse.getEntity(),HTTP.UTF_8);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
返回的result字符串输出来xml格式都没问题,但用pull解析就报错了
Error parsing document. (position:line -1, column -1) caused by: org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: not well-formed (invalid token);
...全文
145 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
wghdsql66 2013-01-22
  • 打赏
  • 举报
回复
返回的xml格式有问题,自己看一下xml是不是多了什么特殊的字符

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧