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
| package Affichage;
import java.io.*;
import org.jdom.*;
import org.jdom.output.*;
public class Insertion
{
static Element racine = new Element("journal");
static org.jdom.Document document = new Document(racine);
public static void main(String[] args)
{
Element log = new Element("log");
racine.addContent(log);
Element type = new Element("type");
type.setText("Demande d'information");
log.addContent(type);
Element date = new Element("date");
date.setText("01/03/2008");
log.addContent(date);
Element heure = new Element("heure");
heure.setText("12:53:10");
log.addContent(heure);
enregistre("Exercice1.xml");
}
static void enregistre(String fichier)
{
try
{
XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
sortie.output(document, new FileOutputStream(fichier));
}
catch (java.io.IOException e){}
} |