I'm developing a weather application. The Xml file is successfully parsed. But I want to read this value.
<yweather:astronomy sunrise="6:03 am" sunset="6:17 pm"/>
But when I get astronomy to a text feild, it returns null. But In logcat it is shows that astronomy tag has been passed.
I want to get the values of sunrise and sunset. Please help me with this. Thanks in advance
XmlHelper.java
@Override
public void endElement(String uri, String localName, String qName) throws SAXException
{
currTag = false;
if(localName.equalsIgnoreCase("pubDate")) post.setDescription(currTagVal);
else if(localName.equalsIgnoreCase("lastBuildDate")) post.setLastBuildDate(currTagVal);
else if(localName.equalsIgnoreCase("yweather:location city")) post.setLocation(currTagVal);
else if(localName.equalsIgnoreCase("channel")) Yweather.add(post);
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
Log.i(TAG, "TAG: " + localName);
currTag = true; currTagVal = ""; // Whenever <post> element is encountered it will create new object of PostValue
if(localName.equals("channel"))
{
post = new WeatherValues();
}
}
MainActivity.java
@Override
protected void onPostExecute(Void result)
{
StringBuilder builder = new StringBuilder();
for(WeatherValues post : helper.Yweather) {
builder.append(post.getLocation());
}
tvResponse.setText(builder.toString());
pd.dismiss();
}
}
This is the xml file http://weather.yahooapis.com/forecastrss?w=2189713