org.xml.sax.SAXParseException:

w937317304 2012-04-13 10:48:41
URL url = new URL("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx");
Document doc;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputStream is = url.openStream();
doc = db.parse(is);


异常信息[Fatal Error] :46:295: The element type "p" must be terminated by the matching end-tag "</p>".
org.xml.sax.SAXParseException: The element type "p" must be terminated by the matching end-tag "</p>".
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:239)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124)
at UrlContext2.main(UrlContext2.java:19)
...全文
183 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
w937317304 2012-04-21
  • 打赏
  • 举报
回复
谢谢chifengxin嗯的确如你所说咯
迟一刀 2012-04-13
  • 打赏
  • 举报
回复
Html是弱格式化语言,而不是标准xml格式。你可以把获取的数据全部打印出来,看是否有不符合xml格式的地方。
BufferedReader br=new BufferedReader( new InputStreamReader(url.openStream()));
String text;
while((text=br.readLine())!=null){
System.out.println(text);
}
w937317304 2012-04-13
  • 打赏
  • 举报
回复
嗯知道是转换出错,可是不知道是什么原因。。。
丙寅 2012-04-13
  • 打赏
  • 举报
回复
楼主你想问的是怎么解决这个错误么??
貌似类型转换出错了

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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