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
| import java.io.FileOutputStream;
import org.jdom.*;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
public class TestJd {
public static void enregistre(Document document,String fichier){
try{
XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
sortie.output(document, new FileOutputStream(fichier));
}catch (java.io.IOException e){
System.exit(10);
}
}
public static void main(String[] args) {
Element racine = new Element("measCollecFile","http://www.3gpp.org/ftp/specs/archive/32_series/32.401/32401-610.zip#measCollec");
Document document = new Document(racine);
Element h = new Element("fileHeader","");
Comment c = new Comment ("test de commentaire");
h.setContent(c);
racine.addContent(h);
Element measData = new Element("measData","http://www.3gpp.org/ftp/specs/archive/32_series/32.401/32401-610.zip#measCollec");
racine.addContent(measData);
Element fileFooter = new Element("fileFooter","http://www.3gpp.org/ftp/specs/archive/32_series/32.401/32401-610.zip#measCollec");
racine.addContent(fileFooter);
enregistre(document,"c:\\test.xml");
}
} |