I develop an android app, which needs among others to parse weather data from YR.no. This organization offers an api with methods that provide certain data on xml format. Let’s say for example I want to parse xml data from this http://api.yr.no/weatherapi/seaapproachforecast/1.0/?location=stad
I managed to parse the attributes of a child element through the question that I made here -> Parse xml from internet (yr.no)
Now I want to parse the data for a specific time. So I want to parse the values of the attributes “from” and “to” of the “time” tag. But the problem is that I cannot set an end text element listener to the node “time” cause I get this error.
"This element already has children. It cannot have an end text element listener."
So how should I parse the attributes of this? Details on my coding may be seen on the link of my previews question that I provided. Thank you in advance!
To parse attributes you have to use a StartElementListener not an end text listener
time.setStartElementListener(new StartElementListener(){
public void start(Attributes attr)
{
String value = attr.getValue("from");
currentMessage.setFrom(value);
}
});