Hello Felix i'm actually trying to make a parser XML which return a
table for display in a listview.
I make this code and it not work (the logcat don't teach me more about
the error)
can you tell me if you see anything wrong ?

java class:

import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;


public class Xml extends ListActivity {




        @SuppressWarnings("unchecked")
        public  ArrayList<String> renvoi_liste_recette_xml() throws Exception
{

        ArrayList<String> aTableRetour = new ArrayList<String>();
        URL myURL = new URL("http://benji.roullet.free.fr/testXml.xml";);
          DocumentBuilderFactory fabrique = DocumentBuilderFactory.newInstance
();
          DocumentBuilder constructeur = fabrique.newDocumentBuilder();
          Document document = constructeur.parse(myURL.openStream());
          Element racine = document.getDocumentElement();
          NodeList liste = racine.getElementsByTagName("contacts");
          for(int i=0; i<liste.getLength(); i++){
                  ArrayList<String> aTableauTmp =  new ArrayList<String>();
                  Element E1= (Element) liste.item(i);
                  aTableauTmp.addAll((Collection<? extends String>)
E1.getElementsByTagName("nom"));
                  aTableRetour.addAll(aTableauTmp);

          }

        return aTableRetour;

}


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
        ArrayList<String> array_list = null;
        try {
                array_list = renvoi_liste_recette_xml();
        } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
        }
    super.onCreate(savedInstanceState);
    setListAdapter(new ArrayAdapter<String>(this,
R.layout.liste,array_list));

    }
}

(the internet permission is well put in the manifest)

thanks
Sweet

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to