Voila je suis debutant en java et je devrais faire un fichier xml ressemblant a ca:
Code XML : 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 <?xml version="1.0" encoding="UTF-8"?> <personnes> <client> <nom>tartempion</nom> <prenom>Jerome</prenom> <adresse>rue des pas perdus</adresse> <cp>1380</cp> <ville>trouperdu ville</ville> <telephonne>+32 635 47 39</telephonne> </client> <client> <nom>escampette</nom> <prenom>Jerome</prenom> <adresse>rue de la gare</adresse> <cp>1880</cp> <ville>jesuisperduville</ville> <telephonne>+32 635 78 32</telephonne> </client> <client> .... .... .... </client> </personnes>
j'ai donc choisis de me pencher sur JDOM et je m'y casse malheureusement les dents
apres moulte tuto je suis peniblement arrive a un fichier xml contenant un et un seul client impossible d'en mettre plus voyez:
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 <?xml version="1.0" encoding="UTF-8"?> <personnes> <client> <nom>tartempion</nom> <prenom>Jerome</prenom> <adresse>rue des pas perdus</adresse> <cp>1380</cp> <ville>trouperdu ville</ville> <telephonne>+32 635 47 39</telephonne> </client> </personnes>
avec le code:
quelqu'un pourrait-il m'aider je commence a desesperer
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 import java.io.*; import org.jdom.*; import org.jdom.output.*; public class JDOM1 { static Element racine = new Element("personnes"); static org.jdom.Document document = new Document(racine); public static void main(String[] args) { Element client = new Element("client"); racine.addContent(client); Element nom = new Element("nom"); nom.setText("tartempion"); client.addContent(nom); Element prenom = new Element("prenom"); prenom.setText("Jerome"); client.addContent(prenom); Element adresse = new Element("adresse"); adresse.setText("rue des pas perdus"); client.addContent(adresse); Element cp = new Element("cp"); cp.setText("1380"); client.addContent(cp); Element ville = new Element("ville"); ville.setText("trouperduville"); client.addContent(ville); Element telephonne = new Element("telephonne"); telephonne.setText("+32 635 47 39"); client.addContent(telephonne); affiche(); enregistre("client.xml"); } static void affiche() { try { XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat()); sortie.output(document, System.out); } catch (java.io.IOException e){} } static void enregistre(String fichier) { try { XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat()); sortie.output(document, new FileOutputStream(fichier)); } catch (java.io.IOException e){} } }
"computer win palpy is K.O."
![]()
Partager