public void saveXml(String xmlFileName){	
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();        
        try {
            DocumentBuilder db = factory.newDocumentBuilder();
            DOMImplementation domImplementation = db.getDOMImplementation();
            Document doc = domImplementation.createDocument(null, "XML_File", null);
            
            buildTree(doc, doc.getDocumentElement());
            
            TransformerFactory transformerFactory = TransformerFactory.newInstance();
            Transformer transformer = transformerFactory.newTransformer();
            
            Properties transfProps = new Properties();
            transfProps.put("method", "xml");
            transfProps.put("indent", "yes");
            transformer.setOutputProperties(transfProps);
            
            DOMSource source = new DOMSource(doc);
            OutputStream out = new FileOutputStream(new File(xmlFileName));
            StreamResult result =  new StreamResult(out);
            
            transformer.transform(source, result);
            try {
                out.close();
            } catch (Exception ex) {}            
        } catch (Exception ex) {
            System.err.println("XML error\n"+ex.toString());
        }		        
	}