salut aide moi svp
j'ai un problème pour parcourir les childs de fichier xml voici mon fichier:
et le bout de code java qui j'utilisé:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 <?xml version="1.0" encoding="UTF-8"?> <Root> <carte> <child0>54.777863</child0> <child1>60.17382</child1> <child2>56.920166</child2> <child3>22.06515</child3> <child4>25.063942</child4> <child5>50.146286</child5> <child6>236.0</child6> <child7>40.920708</child7> <child8>39.158314</child8> <child9>30.67977</child9> <child10>45.016518</child10> <child11>45.784428</child11> <child12>16.721846</child12> <child13>35.380493</child13> <child14>26.441618</child14> <child15>63.0</child15> </carte> </Root>
donc mon problème est à l'affichage du tableau chemains (de type String) contient que 54.777863 et les autres case reste null ma question c'est comment remplir mon tableau par tout des child de mon fichier xml???????
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 String chemains[]=new String[15]; static String[] fichierXML() { SAXBuilder sxb = new SAXBuilder(); try { document = sxb.build(new File("/FILE/base.xml")); } catch(Exception e){} racine = document.getRootElement(); List list = racine.getChildren("carte"); Iterator i = listImages.iterator(); int j = 0; while(i.hasNext()) { Element courant = (Element)i.next(); chemains[j] = courant.getChild("child"+j+"").getText(); j++; } return chemains; }
Partager