As you can see in the below xml there are two duplicate fields or nodes called condition (one in <current_conditions>
and the other in <forecast_conditions>
. so whenever i use the startelement
method to read the condition I always get the last last one but i want to read from the first node only).
<current_conditions>
<condition data="Mostly Cloudy"/>
<temp_f data="86"/>
<temp_c data="30"/>
<humidity data="Humidity: 25%"/>
<icon data="/ig/images/weather/mostly_cloudy.gif"/>
<wind_condition data="Wind: SE at 7 mph"/>
</current_conditions>
<forecast_conditions>
<day_of_week data="Sun"/>
<low data="73"/>
<high data="97"/>
<icon data="/ig/images/weather/mostly_sunny.gif"/>
<condition data="Mostly Sunny"/>
I can I do that. I am using SAX parser to parse the document and here is the code for the handler I am using
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
if (localName.equals("condition")) {
String data=attributes.getValue("data");
}}