| 12
 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
 
 | package eda;
 
import java.io.*;
import org.jdom.*;
import org.jdom.output.*;
 
public class XMLParser {
 
 
 
    public static boolean addSkin(String nom, String type, String filename, String size, String image) {
        if(nom != null && type != null && filename != null && size != null && image != null) {
            try {    
                Element skin = new Element("Skin");
                Element snom = new Element("name");
                snom.setText(nom);
                Element stype = new Element("type");
                stype.setText(type);
                Element sfilename = new Element("filename");
                sfilename.setText(filename);
                Element ssize = new Element("size");
                ssize.setText(size);
                Element simage = new Element("image");
                simage.setText(image);
 
                root.addContent(skin);
 
                skin.addContent(snom);
                skin.addContent(stype);
                skin.addContent(sfilename);
                skin.addContent(ssize);
                skin.addContent(simage);
                saveXML();
                return true;
            /*} catch (IOException ioe) {
                ioe.printStackTrace();*/
            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }
        } else return false;
    }
 
    private static void saveXML() {
        try {
            XMLOutputter outp = new XMLOutputter(Format.getPrettyFormat());
            outp.output(document, new FileOutputStream("/root/NetBeansProjects/eda/web/moh/skins.xml"));
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
 
    static Element root = new Element("moh");
    static org.jdom.Document document = new Document(root);
 
} | 
Partager