|
org.xmlpull.v1.XmlPullParserException: Error parsing document. (position:line -1, column -1) caused by: org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 265: not well-formed (invalid token)在实际的开发中我们发送请求访问服务器端,当返回的是xml格式的InputStream对象时,有时我们采用解析方法如sax, pull 对流进行解析时会出现上面的情况,显示解析,这时可以将流对象读取到内存中转换成字符串,在以流的方式从内存中读出。重新解析就可以得到正确的集合对象 public static byte[] readInput(InputStream in ) throws IOException{ public static InputStream getStringStream(String sInputString){ |
本文介绍了解决XML解析过程中出现的“not well-formed (invalid token)”错误的方法。通过将输入流转换为字符串再重新构建输入流的方式,成功解决了XML解析异常问题。
3839

被折叠的 条评论
为什么被折叠?



