Bonjour,

J'ai un fichier XML qui se présente sous cette forme :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
<Records>
<Record>
<Row A="ecole" B="20-03-2014" C="12:00:00 AM" D="STN40" E="STN32" F="0" G="Boxes MC"/>
</Record>
<Record>
<Row A="ecole" B="20-03-2014" C="12:00:00 AM" D="STN28" E="STN50" F="0" G="Boxes MC"/>
</Record>
<Record>
<Row A="ecole" B="20-03-2014" C="12:00:00 AM" D="STN26" E="STN75" F="0" G="Boxes MG"/>
</Record>
<Record>
<Row A="ecole" B="20-03-2014" C="12:01:00 AM" D="STN40" E="STN30" F="0" G="Boxes MG"/>
</Record>
Et j'utilise une boucle for pour itérer dans tout mon fichier. Cependant je n'arrive pas à utiliser un fonction qui me permet d'avoir le noeud suivant. Quand je met "Record", cela me dit que ce n'est pas un noeud.. je ne comprend pas. Mais cela sera plus facile de voir mon erreur avec un code

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
float calcNextOrderTime(String current_location) throws JDOMException, IOException
    {
        RetreivedHashmap map = new RetreivedHashmap();
        TestDeserialization test = new TestDeserialization();
        float time = 0;
        float t1 = 0;
        float t2 = 0;
        List <Element> record = test.getXMLressources().getChildren("Record");
        for (Element rec : record) {
            List <Element> Row = rec.getChildren("Row");
            Iterator<Element> it2 = Row.iterator(); 
            Element row = it2.next();
            
            String next_location = row.getAttributeValue("E");
            current_order = (current_location+","+next_location);
            t1 = map.hmap.get(current_order);
            System.out.println("Order : " + current_order +" --> time for the order: "+ t1);
            
//Jusqu'ici tout va bien, mais c'est juste après, quand j'appelle le node que ya un probleme
            
//            Node rootElement = getNextSiblingElement("Record"));

            String go_next_order = (row.getAttributeValue("E")+","+getNextSiblingElement("Record")); // Cette ligne me dit incompatible types: String cannot be converted to Node

//            t2 = map.hmap.get(go_next_order);
//            System.out.println("Order : " + go_next_order +" --> time for the order: "+ t2);
            
        }
        time = t1+t2;
        return time;
    }

      /** Finds and returns the next sibling element node. */
    public static Element getNextSiblingElement(Node node)
    {
        TestDeserialization test = new TestDeserialization();
        Element root = test.root;
        // search for node
        Node sibling = node.getNextSibling();
        while (sibling != null) {
            if (sibling.getNodeType() == Node.ELEMENT_NODE) {
                return (Element)sibling;
            }
            sibling = sibling.getNextSibling();
        }

        // not found
        return null;

    }
Le fichier XML est lu dans un autre classe ( TestDeserialization)
Je dois utiliser l'élément suit (Record) dans l'itération juste avant de la boucle for.

Merci pour l'aide que vous pourrez m'apporter.