내 앱에서 weather xml api를 구문 분석하려고하지만 API의 URL을 구문 분석하는 동안 예외가 발생합니다. 다음은 logcat의 스크린 샷입니다. 예외가 라인 (654)에서 발생하는 로그 캣 관찰에서 안드로이드에서 URL 구문 분석에 예외가 발생합니다. Java
와 나는 내가 issue.You 아래 코드에서 문을 확인할 수 있습니다 해결 방법을 알고 해달라고, 라인 (654)에xr.parse(new InputSource(url.openStream()));
문을 가지고 있지만. 이 점에서 저를 도우십시오. 귀하의 답변은 높이 평가 될 것입니다. 미리 감사드립니다.
여기 내 코드입니다.
private void parseWeatherURL(String strURL)
{
try
{
String weatherURL="http://api.worldweatheronline.com/free/v1/weather.ashx?key=476yv2t87x67j5pzb7hbazn6&q=34.25,71.014&cc=yes&num_of_days=5&format=xml";
/* Replace blanks with HTML-Equivalent. */
URL url = new URL(weatherURL.replace(" ", "%20"));
Log.e("Weather", "URL");
/* Get a SAXParser from the SAXPArserFactory. */
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
Log.e("Weather", "SAX");
/* Get the XMLReader of the SAXParser we created. */
XMLReader xr = sp.getXMLReader();
com.ifahja.weather.WeatherHandler myWeatherHandler = new com.ifahja.weather.WeatherHandler();
xr.setContentHandler(myWeatherHandler);
Log.e("Weather", "Handler");
/* Parse the xml-data our URL-call returned. */
xr.parse(new InputSource(url.openStream()));
//Log.d(TAG, "it's all right");
Log.e("Weather URL", "it's all right");
}
catch(Exception e)
{
Log.e("Problem", "parseWeatherURL()");
e.printStackTrace();
}
}