Bonjour à tous !
J'ai suivi le cours "Manipulation des données XML avec JAVA et JDOM" écrit par Nicolas CYNOBER, en ligne sur le site.
Je rencontre malheureusement un problème dès la première partie du cours concernant la création d'une arborescence simple. En effet, j'ai un problème dès le premier programme d'exemple qui est le suivant :
voici le message d'erreur, attention ça pique :Code:
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 import java.io.*; import org.jdom.*; import org.jdom.output.*; public class JDOM1 { //Nous allons commencer notre arborescence en créant la racine XML //qui sera ici "personnes". static Element racine = new Element("personnes"); //On crée un nouveau Document JDOM basé sur la racine que l'on vient de créer static org.jdom.Document document = new Document(racine); public static void main(String[] args) { //On crée un nouvel Element etudiant et on l'ajoute //en tant qu'Element de racine Element etudiant = new Element("etudiant"); racine.addContent(etudiant); //On crée un nouvel Attribut classe et on l'ajoute à etudiant //grâce à la méthode setAttribute Attribute classe = new Attribute("classe","P2"); etudiant.setAttribute(classe); //On crée un nouvel Element nom, on lui assigne du texte //et on l'ajoute en tant qu'Element de etudiant Element nom = new Element("nom"); nom.setText("CynO"); etudiant.addContent(nom); //Les deux méthodes qui suivent seront définies plus loin dans l'article affiche(); enregistre("Exercice1.xml"); } }
Apparemment, Eclipse ne peut pas accéder au librairies JDOM télécharger.Citation:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The constructor Element(String) is undefined
The method addContent(Element) is undefined for the type Element
Attribute cannot be resolved to a type
Attribute cannot be resolved to a type
The constructor Element(String) is undefined
The method setText(String) is undefined for the type Element
The method addContent(Element) is undefined for the type Element
The method affiche() is undefined for the type JDOM1
The method enregistre(String) is undefined for the type JDOM1
at JDOM1.main(JDOM1.java:21)
J'ajoute que ces fichier jdom-2.0.6 on été rajouter dans mon projet en faisant :
clic droit sur mon projet --> Build Path --> Configure Build Path --> onglet Library --> Adds external Jars
Les fichier .jar on bien été rajouté dans mon répertoire projet...
Alors franchement je ne comprends pas le problème, si vous pensez savoir d'où cela peut provenir, n'hésitez pas !
Merci d'avance.