public void encoder(Circuit c, String endroit){
        try {
            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuild = docFactory.newDocumentBuilder();
            
            Document doc = docBuild.newDocument();
            root = doc.createElement("circuit");
            
            root.setAttribute("AMPERE", Double.toString(c.getAmpere()));
            root.setAttribute("VOLTAGE", Double.toString(c.getVoltage()));
            
            doc.appendChild(root);
            
            setComp(root, c, doc);
            
            Element composante = doc.createElement("COMPOSANTE");
            
            for(Composante comp : c.getComposantes()) {
                Element elem = doc.createElement(comp.getType().toString());
                if(comp.getType() == Type.PARALLELE) {
                    setComp(elem, comp, doc);
                    encoderPara((Parallele)comp, doc, elem);
                } else {
                    setComp(elem, comp, doc);
                }
                
                composante.appendChild(elem);
            }
            
            root.appendChild(composante);
            
            TransformerFactory transFactory = TransformerFactory.newInstance();
            Transformer aTransformer = transFactory.newTransformer();
            
            Source src = new DOMSource(doc);
            Result dest = new StreamResult(new File(endroit + ".circuit"));
            
            aTransformer.transform(src, dest);
        } catch (ParserConfigurationException | TransformerException ex) {
            Logger.getLogger(GestionXML.class.getName()).log(Level.SEVERE, null, ex);
        }
    }