我正在尝试解析下一个网址: http://kavim-t.co.il/include/getXMLStations.asp?parent= 55_%20_2
代码:
//using jdom SAX parser
SAXBuilder builder = new SAXBuilder();
URL url = new URL("http://kavim-t.co.il/include/getXMLStations.asp?parent=55_%20_2");
InputStream in = getInputStrem(url);
Document document = builder.build(in); ...
获取输入流():
public static InputStream getInputStrem(URL url) {
InputStream in = null;
try {
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.connect();
in = con.getInputStream();
} catch (IOException e) {
e.printStackTrace();
}
return in;
}
异常“第 3 行错误:第 3 行第 29 列:格式不正确(无效令牌)”
尝试运行下一行时得到:
Document document = builder.build(in)
我认为问题出在 getInputStream() 函数中,
因为如果我将 Url 替换为更简单的(没有参数和经典结构),它工作正常。