Bonjour,

Je tente de lire les noeuds fils de mon fichier xml mais sans résultat.

Je travaille sous Eclipse et j'utilise JDOM

Voici 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
<?xml version="1.0" encoding="UTF-8"?>
<!--declaration de la racine-->
 
<typesInformations>
    <typeInformation>
        <nomTypeInformation>facutre</nomTypeInformation>
        <delaisTypeInformation>10</delaisTypeInformation>    
        <unitesInformations>
             <uniteInformation>
                <nom>factureUnite1</nom>
                <prenom>idfact1</prenom>
            </uniteInformation>
 
            <uniteInformation>
                <nom>factureUnite2</nom>
                <prenom>idfact2</prenom>
            </uniteInformation>
        </unitesInformations>
        </typeInformation>
</typesInformations>
Je cherche à lire unitesInformations
Voici le code Java
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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.XML;
 
import java.io.*;
 
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.filter.*;
import java.util.List;
import java.util.Iterator;
 
public class ReaderXML
{
    /*-------------------------- création de l'element racine -------------------*/
        static Element racine ;
 
    /*----- creation d'un nouveau document basé sur la racine -------------------*/
        static org.jdom.Document document;
 
    /*----- afficherAll(), permet d'afficher les elements du document XML--------*/
        static void afficherAll(Element racine ,org.jdom.Document document )
           {
              List liste = racine.getChildren("typeInformation");
              Iterator i = liste.iterator();
              List ll =null;
              while (i.hasNext())
               {
                  org.jdom.Element courant = (Element)i.next();
                  System.out.println( courant.getName());
                  System.out.println(courant.getChild("nomTypeInformation").getText());
                  System.out.println(courant.getChild("delaisTypeInformation").getText());
                   System.out.println(racine.getChild("typeInformation").getChild("unitesInformations").getChild("uniteInformation").getChild("nom").getText());//.getChild("page").getAttributeValue("name"));
                   System.out.println(racine.getChild("typeInformation").getChild("unitesInformations").getChild("uniteInformation").getChild("prenom").getText());//.getChild("page").getAttributeValue("name"));
 
                  System.out.println();
               }    
      }   
}
Je ne réussis qu'à lire le premier. Lors de l’exécution il affiche :
nomTypeInformation : facutre
delais : 10
idfact1
Quelqu'un saurait-il m'expliquer comment procéder ?

Merci d'avance pour votre aide.