Sax parser issues in android
<p>I'm trying to parse a xml using SAX parser. The code works fine on pc but on android the elements doesn't get added to list .
In the code i'm trying to add the data within the tags sunrise &amp; sunset onto the list array</p>

<p>In public 
     void endElement(..) {} </p>

<p>System.out.println("size of list " + timeLst.size());   //Always shows 0 in android </p>

<p>Below is the code..</p>

<pre><code>TimeServiceParser tsp = new TimeServiceParser();
tsp.parseDocument(new URL("http://www.earthtools.org/sun/47.566667/-52.716667/14/3/99/1"));
tsp.printData();


public class TimeService extends DefaultHandler {

   public void parseDocument(URL sourceUrl) {
        SAXParserFactory spf =  SAXParserFactory.newInstance();

        try{
            SAXParser sp = spf.newSAXParser();
            InputStream is = sourceUrl.openStream();    
            sp.parse(is, this);
        }catch(SAXException se) {               
                ...         
        }

  }


public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {

        tempVal = "";
        if(qName.equalsIgnoreCase("sunrise")) {
                tempTimeData = new TimeData();                      
        }
    }


    public void endElement(String uri, String localName, String qName) throws SAXException {

        if(qName.equalsIgnoreCase("sunrise")) {
                tempTimeData.setSunriseTime(tempVal);
                timeLst.add(tempTimeData);

        }else if(qName.equalsIgnoreCase("sunset")) {
                if(tempTimeData!=null) {
                       TimeData t = (TimeData)(timeLst.get(0));
                       t.setSunsetTime(tempVal);
                }
        }

        System.out.println("size of list " + timeLst.size());   //Always shows 0 in android 
    }


    public void characters(char[] ch, int start, int length) throws SAXException {          
        tempVal = new String(ch , start , length);  

    }

    public void printData() {

        Iterator&lt;TimeData&gt; it = timeLst.listIterator();

        while(it.hasNext()) {
                TimeData td = (TimeData)(it.next());
                System.out.println(td.getSunriseTime());    
                System.out.println(td.getSunsetTime());
        }
    }
</code></pre>

<p>}</p>
