1
を使用して属性の値を解析する方法私はGoogleの天気予報APIレスポンスを解析したい... 応答は同様である:PullParser
<current_conditions>
<condition data="Haze"/>
<temp_f data="82"/>
<temp_c data="28"/>
<humidity data="Humidity: 94%"/>
<icon data="/ig/images/weather/haze.gif"/>
<wind_condition data="Wind: SW at 12 mph"/>
</current_conditions>
now i want only temp_c data to use in my app.
so how can i get the value of temp using xml pull parser..
right now i m doing like that
StringBufferInputStream buffer = new StringBufferInputStream(response);
xpp = XmlPullParserFactory.newInstance().newPullParser();
xpp.setInput(buffer, null);
int eventType = xpp.getEventType();
while(eventType != XmlPullParser.END_DOCUMENT)
{
if(eventType == XmlPullParser.START_TAG){
String elementName = xpp.getName();
if(elementName.equals("current_conditions")){
local_pickup = xpp.nextText();
Log.d("database", local_pickup);
}
}
eventType = xpp.next();
}
buffer.close();
早けれ