안드로이드 개발 질문/답변
(글 수 45,052)
<?xml version="1.0" ?>
<city data="seoul" />
<postal_code data="seoul" />
<latitude_e6 data="" />
<longitude_e6 data="" />
<forecast_date data="2011-07-27" />
<current_date_time data="2011-07-27 07:29:27 +0000" />
<unit_system data="SI" />
</forecast_information>
<condition data="소나기" />
<temp_f data="75" />
<temp_c data="24" />
<humidity data="습도: 94%" />
<icon data="/ig/images/weather/rain.gif" />
<wind_condition data="바람: 동풍, 10 km/h" />
</current_conditions>
<day_of_week data="수" />
<low data="24" />
<high data="24" />
<icon data="/ig/images/weather/thunderstorm.gif" />
<condition data="강우(천둥, 번개 동반)" />
</forecast_conditions>
구글 날씨 API이구요.
case XmlPullParser.START_TAG:
if(parser.getName().equals("current_conditions")){
bcurrent_condition = true;
}
else if(parser.getName().equals("forecast_conditions")){
bforecast_conditions = true;
}
if(bcurrent_condition == true)
{
d_weather.Day = "오늘";
if(parser.getName().equals("condition")){
d_weather.Condition = "날씨 : " + parser.getAttributeValue(0);
}
else if(parser.getName().equals("temp_c")){
d_weather.Temp = "온도 : " + parser.getAttributeValue(0) + "℃";
}
else if(parser.getName().equals("icon")){
d_weather.Image = "http://www.google.com" + parser.getAttributeValue(0);
}
else if(parser.getName().equals("wind_condition")){
d_weather.Wind = parser.getAttributeValue(0);
}
Log.d("bCurrent", "완료");
}
else if(bforecast_conditions == true)
{
Log.d("bforecast", "시작");
if(parser.getName().equals("day_of_week")) {
Log.d("bforecast", "day_of_week1");
d_weather.Day2 = parser.getAttributeValue(0);
Log.d("bforecast", "day_of_week2");
}
else if(parser.getName().equals("low")){
Log.d("bforecast", "2");
d_weather.Temp2 = "최저온도 : " + parser.getAttributeValue(0) + "℃";
Log.d("bforecast", "3");
}
else if(parser.getName().equals("high")){
Log.d("bforecast", "4");
d_weather.Wind2 = "최고온도 : " + parser.getAttributeValue(0) + "℃";
Log.d("bforecast", "5");
}
else if(parser.getName().equals("icon")){
Log.d("bforecast", "6");
d_weather.Image2 = "http://www.google.com" + parser.getAttributeValue(0);
Log.d("bforecast", "7");
}
else if(parser.getName().equals("condition")) {
Log.d("bforecast", "8");
d_weather.Condition2 = "날씨 : " + parser.getAttributeValue(0);
Log.d("bforecast", "9");
}
}
break;
case XmlPullParser.END_TAG:
Log.d("END_TAG", "1");
if(parser.getName().equals("current_conditions")){
Log.d("END_TAG", "2");
bcurrent_condition = false;
if(d_weather != null) {
Log.d("END_TAG", "3");
m_weather.add(d_weather);
d_weather = null;
Log.d("END_TAG", "4");
}
}
else if(parser.getName().equals("forecast_conditions")){
Log.d("END_TAG", "5");
bforecast_conditions = false;
if(d_weather != null) {
Log.d("END_TAG", "6");
m_weather.add(d_weather);
d_weather = null;
Log.d("END_TAG", "7");
}
}
break;
파싱문입니다.
api에 보면 current_condition이 오늘이고 forecast_conditions가 내일날씬데
current_condition만 가져오는걸로 하면 잘 나옵니다.
그런데 forecast_conditions를 가져오려고 하면 멈추네요 ㅠㅠ
에러가 나는것도 아니고 종료되지도 않고 그냥 파싱 자체만 멈춥니다.
백버튼 누르면 다시 뒤로 돌아가구요.
class WeatherData {
String Image;
String Day;
String Condition;
String Temp;
String Wind;
String Image2;
public String getImage2() {
return Image2;
}
public void setImage2(String image2) {
Image2 = image2;
}
String Day2;
public String getDay2() {
return Day2;
}
public void setDay2(String day2) {
Day2 = day2;
}
String Condition2;
public String getCondition2() {
return Condition2;
}
public void setCondition2(String condition2) {
Condition2 = condition2;
}
String Temp2;
public String getTemp2() {
return Temp2;
}
public void setTemp2(String temp2) {
Temp2 = temp2;
}
String Wind2;
public String getWind2() {
return Wind2;
}
public void setWind2(String wind2) {
Wind2 = wind2;
}
public void setImage(String _Image) {
this.Image = _Image;
}
public void setDay(String _Day) {
this.Day = _Day;
}
public void setCondition(String _Condition) {
this.Condition = _Condition;
}
public void setTemp(String _Temp) {
this.Temp = _Temp;
}
public void setWind(String _Wind) {
this.Wind = _Wind;
}
public String getImage() {
return Image;
}
public String getDay() {
return Day;
}
public String getCondition() {
return Condition;
}
public String getTemp() {
return Temp;
}
public String getWind() {
return Wind;
}
}외부 클래스구요.
내부클래스로 해서 문제인것같아서 외부로 돌리고
변수도 다르게 만들어서 값 받아오는데
로그를 찍어보면
d_weather.Day2 = parser.getAttributeValue(0);
딱 여기서 멈추더라구요 ㅠㅠ
문제가 뭔지를 모르겠습니다...
어디가 문제인것같다고만 얘기해주시면 찾아볼게요 ㅠㅠ



