Hello i search a tuto which show how to populate au listview with an
xml file of internet. I found one but it populate with attribut of a
marker:
xml file:
<listerecette>
<recette name= »Le Cari de Boeuf » type= »Repas » Country= »France »
nbrofpers= »4″ level= »" content= »Coupez le boeuf en morceaux
(style daube). Émincez les oignons, coupez les tomates en petits
morceaux et pilez ail, sel poivre e… »>
</recette>
…
<listerecette>
Java:
public ArrayList<ArrayList> renvoi_liste_recette_xml() throws
Exception{
ArrayList<ArrayList> aTableRetour = new ArrayList<ArrayList>();
URL myURL = new URL("http://www.dgentreprises.com/recette/
listerecette.php");
DocumentBuilderFactory fabrique = DocumentBuilderFactory.newInstance
();
// création d'un constructeur de documents
DocumentBuilder constructeur = fabrique.newDocumentBuilder();
Document document = constructeur.parse(myURL.openStream());
Element racine = document.getDocumentElement();
NodeList liste = racine.getElementsByTagName("recette");
for(int i=0; i<liste.getLength(); i++){
ArrayList<String> aTableauTmp = new ArrayList<String>();
Element E1= (Element) liste.item(i);
//aTableRetour[i]= "";
aTableauTmp.add(E1.getAttribute("name"));
aTableauTmp.add(E1.getAttribute("content"));
aTableRetour.add(aTableauTmp);
}
return aTableRetour;
I give you an exemple of my xml file(i would like to populate my
listview with the content of markers and not attributs):
xml file:
<liste>
<item>
<nom>L'ours blanc</nom>
<heberg>Hotel ****</heberg>
<tel>321-123-4567</tel>
<email>[email protected]</email>
</item>
<item>
<nom>Le coin du paradis</nom>
<heberg>Chambres d'hotes</heberg>
<tel>0450257569</tel>
<email>[email protected]</email>
</item>
<item>
<nom>L'Albanc</nom>
<heberg>Hotel **</heberg>
<tel>0473589898</tel>
<email>[email protected]</email>
</item>
</liste>
If anyone know a tuto for that or if anyone can help me to fit the
fist code to my xml file it will be great because i'm blocked here ...
Thanks
Sweet
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---