bonjour,

je veux ajouter un element a mon fichier xml voila le code que j'ai utilisé,
le fichier xml existe deja
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
  public void ajouter_article(Article art)
       {
             System.out.print("la fonction ajouter Article");
             Element racine;
             org.jdom.Document document=null;
             SAXBuilder sxb=new SAXBuilder();
             try
             {
                 document=sxb.build(new File("article.xml"));  
             }
             catch(Exception e)
             {
                e.printStackTrace();
             }
             racine=document.getRootElement(); 
             Element article=new Element("article");
             racine.addContent(article);
             Element id=new Element("id");
             id.setText(String.valueOf(art.getIdentifiant()).toString());
             article.addContent(id);
             Element prix=new Element("prix");
             id.setText(String.valueOf(art.getPrix()).toString());
             article.addContent(prix);
             Element libelle=new Element("libelle");
             id.setText(art.getLibelle());
             article.addContent(libelle);
           /************ enregistrement des modifications dans le fichier **********/
             XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
             try
             {
                 sortie.output(document, new FileOutputStream("article.xml"));  
             }
             catch(Exception e)
             {
                   e.printStackTrace();
             }
         System.out.print(" fin ajouter Article \n ");
       }
il m'affiche une erreur de compilation
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
 
 
Exception in thread "main" java.lang.NumberFormatException: For input string: "ee"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Long.parseLong(Long.java:403)
        at java.lang.Long.parseLong(Long.java:461)
        at IHM.Article.lire_article(Article.java:188)
        at article_projet.Main.main(Main.java:31)
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "ee"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Long.parseLong(Long.java:403)
        at java.lang.Long.parseLong(Long.java:461)
        at IHM.Article.lire_article(Article.java:188)
        at IHM.F_Acceuil.<init>(F_Acceuil.java:32)
        at article_projet.Main$1.run(Main.java:24)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
merci pour l'aide