<?xml version="1.0" encoding="gb2312"?>
<csResponse>
<CsClient>
<idext>hehe</idext>
<clientname>hehe</clientname>
<linkman>hehe</linkman>
<phone>hehe</phone>
<kind>hehe</kind>
<memberstate>hehe</memberstate>
<regtime>hehe</regtime>
<sex>hehe</sex>
<logouttime>hehe</logouttime>
</CsClient>
</csResponse>
为什么解析的时候总是说:
[Fatal Error] :-1:-1: Premature end of file.
org.xml.sax.SAXParseException: Premature end of file.
问了一些朋友,他们说是在<?xml version="1.0" encoding="gb2312"?>之前有字符。可是这段XML我是
用如下方法生成的,还是有错吗?
response.setContentType("text/xml");
StringBuffer sb=new StringBuffer();
sb.append("<?xml version=\"1.0\" encoding=\"gb2312\"?><csResponse><CsClient>");
sb.append("<idext>hehe</idext>");
sb.append("<clientname>hehe</clientname>");
sb.append("<linkman>hehe</linkman>");
sb.append("<phone>hehe</phone>");
sb.append("<kind>hehe</kind>");
sb.append("<memberstate>hehe</memberstate>");
sb.append("<regtime>hehe</regtime>");
sb.append("<sex>hehe</sex>");
sb.append("<logouttime>hehe</logouttime>");
sb.append("</CsClient></csResponse>");
response.getWriter().print(sb);
response.getWriter().flush();
response.getWriter().close();
out.println(sb);
这样都会有错吗?