Xml

hakim -  
 hakim -
Bonjour,
Document document = builder.build(new File("patronsyntax.xml"));
Element racine = document.getRootElement();
java.util.List ls=racine.getChildren();
Element p1=(Element) ls.get(0);
java.util.List ls1= p1.getChildren() ;
Element pp=(Element) ls1.get(0);
java.util.List ls3= pp.getChildren() ;
Element pn=(Element) ls3.get(0);
Element p2=(Element) ls.get(1);
java.util.List hb= p2.getChildren() ;
Element pp1=(Element) hb.get(0);
java.util.List hb2= pp1.getChildren() ;
Element pn2=(Element) hb2.get(0);
Element p3=(Element) ls.get(2);
java.util.List hk= p3.getChildren() ;
Element pp2=(Element) hk.get(0);
java.util.List hk2= pp2.getChildren() ;
Element pn3=(Element) hk2.get(0);
Element p4=(Element) ls.get(3);
java.util.List bm= p4.getChildren() ;
Element pp3=(Element) bm.get(0);
java.util.List bm2= pp3.getChildren() ;
Element pn4=(Element)bm2.get(0);

salut je cherche de transformer ce parcour de fichier XML"patronsyntax.xml" par une boucle et non pas chaque element tout seul pour me permettre d'ajouter d'autres element a partir du fichier XML automatiquement sans retour au code
Configuration: Windows XP
Internet Explorer 6.0

2 réponses

  1. nabla
     
    Bonjour.

    en quel langage travailles tu ?
    0
    1. hakim
       
      salut
      je travail avec java sur netbeens
      0
  2. magicwill Messages postés 94 Statut Membre 3
     
    C'est pas tres clair je pense ta question, mais pour faire une boucle sur tes elements, tu fais:

    Document document = builder.build(new File("patronsyntax.xml"));
    Element racine = document.getRootElement();

    for (Element elt : racine.getChildren())
    {
       for (Element elt2 : elt.getChildren())
       {
        // etc...
        }
    }
    
    0