Retrieving data from XML using SAX parsing retieves only first and last value
<p>I am parsing data from a web service shown below: I am only able to parse two values that are status and bal and coming next to that i am getting null pointer exception.
I am able to retrieve only status and lname.Can anyone tell me what is the problem with this. I am getting 
status = 1 which is correct, bal = Finn, and rest are null.</p>

<p>XML:</p>

<pre><code>&lt;root&gt;
&lt;response&gt;
&lt;status&gt;1&lt;/status&gt;
&lt;bal&gt;3.69 EUR&lt;/bal&gt;
&lt;cur&gt;EUR&lt;/cur&gt;
&lt;acc&gt;2974342749&lt;/acc&gt;
&lt;fname&gt;Welcome To&lt;/fname&gt;
&lt;lname&gt;Finn&lt;/lname&gt;
&lt;/response&gt;
&lt;/root&gt;
</code></pre>

<p>Code:</p>

<p>Main Activity</p>

<pre><code>btn.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                new Communicator().execute();
            }
        });
}

public class Communicator extends AsyncTask&lt;String, String, SitesList1&gt;
{
    @Override
        protected SitesList1 doInBackground(String... params) {
            try {
                    SAXParserFactory spf = SAXParserFactory.newInstance();
                    SAXParser sp = spf.newSAXParser();
                    XMLReader xr = sp.getXMLReader();

                    URL sourceUrl = new URL("XXXXX![enter image description here][2]");
                    MyXMLHandler1 myXMLHandler1 = new MyXMLHandler1();
                    xr.setContentHandler(myXMLHandler1);
                    xr.parse(new InputSource(sourceUrl.openStream()));
            } catch (Exception e) {
                System.out.println("XML Pasing Excpetion = " + e);
            }

            sitesList1 = MyXMLHandler1.sitesList1;

            return sitesList1;
        }

        @Override
        protected void onPreExecute() 
        {
            super.onPreExecute();
        }

        @SuppressWarnings("deprecation")
        @Override
        protected void onPostExecute(SitesList1 result) 
        {
                status = sitesList1.getStatus().toString();
                System.out.println("status"+status);
                bal = sitesList1.getBal().toString();
                System.out.println("bal"+bal);
                cur = sitesList1.getCur().toString();
                System.out.println("cur"+cur);
                acc = sitesList1.getAcc().toString();
                System.out.println("acc"+acc);
                fname = sitesList1.getFname().toString();
                System.out.println("fname"+fname);
                lname = sitesList1.getLname().toString();
                System.out.println("lname"+lname);

        }
    }
</code></pre>

<p>Handler:</p>

<p>public class MyXMLHandler1 extends DefaultHandler{</p>

<pre><code>Boolean currentElement = false;
String currentValue = null;
public static SitesList1 sitesList1 = null;

public  SitesList1 getSitesList1() {
    return sitesList1;
}

public  void setSitesList1(SitesList1 sitesList1) {
    this.sitesList1 = sitesList1;
}

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

    currentElement = true;

    if (localName.equals("root")) {
        sitesList1 = new SitesList1();
    }
}

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

    currentElement = false;

    if (localName.equalsIgnoreCase("status"))
        sitesList1.setStatus(currentValue);
    else if (localName.equalsIgnoreCase("bal"))
        sitesList1.setBal(currentValue);
    else if (localName.equalsIgnoreCase("cur"))
        sitesList1.setBal(currentValue);
    else if (localName.equalsIgnoreCase("acc"))
        sitesList1.setBal(currentValue);
    else if (localName.equalsIgnoreCase("fname"))
        sitesList1.setBal(currentValue);
    else if (localName.equalsIgnoreCase("lname"))
        sitesList1.setBal(currentValue);

}

@Override
public void characters(char[] ch, int start, int length)
        throws SAXException {

    if (currentElement) {
        currentValue = new String(ch, start, length);
        currentElement = false;
    }

}
</code></pre>

<p>}</p>

<p>Setter Getter:</p>

<p>public class SitesList1 {</p>

<pre><code>private String status;
private String bal;
private String cur;
private String acc;
private String fname;
private String lname;
public String getStatus() {
    return status;
}
public void setStatus(String status) {
    this.status = status;
}
public String getBal() {
    return bal;
}
public void setBal(String bal) {
    this.bal = bal;
}
public String getCur() {
    return cur;
}
public void setCur(String cur) {
    this.cur = cur;
}
public String getAcc() {
    return acc;
}
public void setAcc(String acc) {
    this.acc = acc;
}
public String getFname() {
    return fname;
}
public void setFname(String fname) {
    this.fname = fname;
}
public String getLname() {
    return lname;
}
public void setLname(String lname) {
    this.lname = lname;
}
</code></pre>

<p>}</p>
