XML doesnt generate correctly android
<p>I got a class that extends <code>AsyncTask</code>, this class is for generating a XML file. Here is my class</p>

<pre><code>import java.io.File;
import java.util.ArrayList;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;

import android.util.Log;
import android.widget.Toast;

public class GenerateXML extends AsyncTask&lt;String, Void, String&gt; {

private final static String TAG = "GENECREATE_XML: "; 

DocumentBuilder docBuilder; 
DocumentBuilderFactory docFactory;

ArrayList&lt;Case&gt; caseArray;
Context c;

ProgressDialog pd; 

String address; 



public GenerateXML(ArrayList&lt;Case&gt; caseArray, Context c) {

    caseArray = new ArrayList&lt;Case&gt;(); 

    this.caseArray = caseArray; 
    this.c = c; 

    address = "/sdcard/case.xml";

}

protected void onPreExecute() {

      pd=ProgressDialog.show(c,"Please Wait..","Generating XML",false);

}

@Override
protected String doInBackground(String... params)  {

    int i = 0; 

    docFactory = DocumentBuilderFactory.newInstance();

    try {
         docBuilder = docFactory.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        Log.e(TAG, e.getMessage()); 
    }

    Document doc = docBuilder.newDocument(); 

    //root element in the xml
    Element rootCase = doc.createElement("Cases"); 
    doc.appendChild(rootCase);


    for(Case cases : caseArray) {

    // case elements
    Element caseElement = doc.createElement("case");
    rootCase.appendChild(caseElement);

    // set attribute to staff element
    Attr attr = doc.createAttribute("id");
    attr.setValue(Integer.toString((++i)));
    caseElement.setAttributeNode(attr);

    // pcn
    Element pcn = doc.createElement("pcn");
    pcn.appendChild(doc.createTextNode(cases.getCaseNumber()));
    caseElement.appendChild(pcn);

    //status
    Element status = doc.createElement("status");
    status.appendChild(doc.createTextNode(Integer.toString(cases.getStatus())));
    caseElement.appendChild(status);

    //date
    Element date = doc.createElement("date");
    date.appendChild(doc.createTextNode(cases.getDate()));
    caseElement.appendChild(pcn);

    }


    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = null;
    try {
        transformer = transformerFactory.newTransformer();
    } catch (TransformerConfigurationException e) {
        Log.e(TAG, e.getMessage()); 
    }

    DOMSource source = new DOMSource(doc);
    StreamResult result = new StreamResult(new File(address));



    try {
        transformer.transform(source, result);
    } catch (TransformerException e) {
        Log.e(TAG, e.getMessage());
    }


    return null;
}

protected void onPostExecute(String result) {
    pd.dismiss(); 
    Toast.makeText(c, "Finished. File saved to: " + address, Toast.LENGTH_LONG).show(); 
}
</code></pre>

<p>}</p>

<p>My XML looks like this:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;Cases/&gt;
</code></pre>

<p>Why doesnt it show the whole content of the <code>ArrayList&lt;Case&gt;</code> ? </p>
